• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disabling a text field leads to loss of value

 
Muthukrishnan Manoharan
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem retrieving value from a disabled text field.

For example, when I retrieve value from a text field which is disabled but has some text in it (i.e., filled with text and disabled), I end up retrieving only empty string not that text.

Can anyone help me how should i retrieve value from that disabled text box. I am using Struts text tag (and Struts version: 1.2)

Thanks,
Muthu
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your JSP, action form and the action class.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some (all?) browsers don't send the values of disabled input elements.
 
Kartik Tal
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you keep any field into disable the values wont go beyond that JSP.
So instead of keeping disable keep them "readonly=true"
 
Muthukrishnan Manoharan
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sagar,
Here is the JSP where i use it. It is a DynaAction Form


and in action I try to get the value as


Kartik,
That was a good option. I am using it..

Apart from that when I googled on this, I came to know that as per HTTP specs, value of the disabled field shouldn't be carried to the server (as David said) and ppl prefer to have hidden field as an alternative to this.

Thanks ppl,
Muthu
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muthukrishnan Manoharan wrote:Apart from that when I googled on this, I came to know that as per HTTP specs, value of the disabled field shouldn't be carried to the server (as David said) and ppl prefer to have hidden field as an alternative to this.

OK, I really don't know about this, thanks for sharing !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic