File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes DropDown Disabled. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "DropDown Disabled." Watch "DropDown Disabled." New topic

DropDown Disabled.

Prasad Tirumareddi

Joined: Feb 17, 2005
Posts: 7

I have a drop down , if i make it disabled i can't capture the value in my servlet. There is no option called readOnly for the dropdown. How can i achieve this.

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
either you have to enable it right before the form is submitted or place the selected value into a hidden element.

Prasad Tirumareddi

Joined: Feb 17, 2005
Posts: 7
Thank You Eric.

But the situation is like this .
The drop downs will be disabled on loading the form depending on the OID Roles / Groups. So sometimes the drop down will be enabled and sometimes not. So i don't know how many drop downs are enabled and how many are not. Making them enabled on submit or validating before submit is like a tedious task. I am looking for a solution by which i can get the values even though they are disabled. Is there any way that cetain style will show the dropdown as disabled but actually not disabled.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

Anything you could come up with would be far messier than what Eric has already suggested. Personally, I'd go with the hidden variable solution.

[Asking smart questions] [About Bear] [Books by Bear]
Kuldeep Vaishnav
Ranch Hand

Joined: May 23, 2004
Posts: 72
yea hidden fields needs to be used.

Prasad Tirumareddi

Joined: Feb 17, 2005
Posts: 7
Bear, i agree with Eric solution.

If i have 20 fields on my page , do you think that 20 hidden variables are to be created. And my pages span more than 20 fields.

I am trying for a better solution. Anyway if i don't i will go with Eric solution. Right now i codded according to Eric.

Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
My guess is you already know when the fields are going to be disabled.
So when you are going to submit the form just change the action attribute of the form by adding all the disabled fields nd their values to the URL.
I know this involves javascript coding to some extent but then you wont need hidden variables.
Since you asked for another option here it is.
If i am wrong guys/gals please correct me.

Life called,so here I am.<br />Cheers<br />Niki.:-)
Don't get me started about those stupid light bulbs.
subject: DropDown Disabled.
jQuery in Action, 3rd edition