Getting the value of a disabled <select> control

Discussion in 'ASP General' started by Eric, Nov 2, 2007.

  1. Eric

    Eric Guest

    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.

    -Eric
     
    Eric, Nov 2, 2007
    #1
    1. Advertising

  2. Eric

    Evertjan. Guest

    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>



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Nov 2, 2007
    #2
    1. Advertising

  3. Eric wrote:
    > 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.

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Nov 3, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NH
    Replies:
    0
    Views:
    586
  2. Meendar
    Replies:
    1
    Views:
    753
  3. Suba
    Replies:
    0
    Views:
    299
  4. palmiere
    Replies:
    1
    Views:
    417
    Erwin Moller
    Feb 9, 2004
  5. Meendar
    Replies:
    1
    Views:
    84
    -Lost
    Apr 12, 2007
Loading...

Share This Page