Getting the value of a disabled <select> control

E

Evertjan.

Eric wrote on 02 nov 2007 in microsoft.public.inetserver.asp.general:
Hello,

I'm trying (without any success) to get the value of a disabled select
control. From reviewing:

http://www.w3.org/TR/html401/interact/forms.html#adef-disabled

It doesn't sound like it's going to be possible directly. I'm
thinking that I can get around it by enabling the select control
during some javascript that gets executed during the submit.


Works fine here [IE7,FF2]:

<select id='a' disabled>
<option value='1'>1</option>
<option value='2' selected>2</option>
<option value='3'>4</option>
</select>

<script type='text/javascript'>

alert(document.getElementById('a').value) // shows 2

</script>
 
B

Bob Barrows [MVP]

Eric said:
Hello,

I'm trying (without any success) to get the value of a disabled select
control.

I'm assuming you want the value in the form's submission.
From reviewing:

http://www.w3.org/TR/html401/interact/forms.html#adef-disabled

It doesn't sound like it's going to be possible directly.
Right
I'm
thinking that I can get around it by enabling the select control
during some javascript that gets executed during the submit.
Either that or use client-side script in the onsubmit event to put the value
in a hidden textbox in the form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top