This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Getting value of Disabled field 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 "Getting value of Disabled field" Watch "Getting value of Disabled field" New topic
Author

Getting value of Disabled field

ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
I Have html select element which i am disabling with onClick of Button,
but in next jsp i am getting its value as null
see the code if option is one and i clicks on button select element gets disabled with value is one but i am not geeting that value "one" in next page , is there any way to get this value
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Disabled means disabled. The value of a disabled control does not get submitted.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
If before making it disabled ..suppose i am setting its value explicitly then is it possible
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If it is disabled before the form is submitted it will not matter what its initial state was, it still will not be sent.

Eric
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
now suppose user is selecting Hocky then there is no point in selecting crickect bat and soccer ball , rite ? thats why i need to disabled it
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You either enable it when the form is sent, or you have a hidden field with the value in it.

Eric
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
not we dont have control on form its runtime gets generated and for hidden values, its not every time i need to disabled field it will based on specific condition

and its not possible to have two fields with same name , you join our company you will get to know more
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Dumb question that must be asked: if you don't want the field disabled, then why are you disabling it?
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
Dear Bear,

Let me explain in general terms




ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
see above if i am selecting hocky then there is no point in selecting cricket bat and soccer ball rite?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

So then, why do you care that it's disabled? You can't have it both ways. If it doesn't matter, why do you care that it's not getting submitted?
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
ok let me explain i have "stuffs" attribute in database which accept only string attributes not even empty string if my field is disabled i am getting null value and setting of attribute value is done by other API to which i can not modified ..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

It's really simple to detect null and replace it with the empty string.
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 230
Bear, i have the solution of this issue but its not that good
i am working on product based company ...i work on the layer which is already defined , i can't touch even that kind of final class
 
GeeCON Prague 2014
 
subject: Getting value of Disabled field