INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Need help understanding using disabled select drop down with hidden input tag?

Need help understanding using disabled select drop down with hidden input tag?

Need help understanding using disabled select drop down with hidden input tag?

(OP)
I need to have the appropriated data selected when a screen displays. I do not want the person to beable to change this so
I will disable the select drop down.

However when the page is submitted I need to get that value.

select has a disabled but no readonly. Therefore the value is not passed

I am looking at possible solutions but what I did not know and want to varify is that
you can have a drop down (select) with a name and an hidden input tag with the same name.

Therefore upon submit the server will only receive the value from the hidden tag?

This is possible?


<form action="demo_form.asp">
<select name="sCar" disabled>
<option value="volvo" selected>Volvo</option>
<option value="saab" >Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<input type="hidden" name="sCar" value="volvo" ><br>
<input type="submit" value="Submit">
</form>

RE: Need help understanding using disabled select drop down with hidden input tag?

As you appear to be writing server side code to render the form, leave the select enabled but only write one option.

RE: Need help understanding using disabled select drop down with hidden input tag?

Why do you need a dropdown if you can't use it? I'd just hide the dropdown and print out a read-only textbox with the value.

In any case, yes, the hidden input will override the value from the dropdown. If at any time the Dropdown does become available the hidden input will need to be disabled or removed to get the value from the dropdown on submission of the form.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close