This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Struts and the fly likes Setting check box as readonly in JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Setting check box as readonly in JSP?" Watch "Setting check box as readonly in JSP?" New topic

Setting check box as readonly in JSP?

Ajay Xavier
Ranch Hand

Joined: Jan 03, 2005
Posts: 109

Consider the following code,

when "${selec.comp.isBoolean}" is true i need to display this check box as readonly and avoid user to edit these fields?
Also I need to the store the values of these check boxes(with ${selec.comp.isBoolean} value true) in a java script array. how to store these values?

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The "readonly" attribute can only be used for <input> tags of type "text" and "password". It won't work for a checkbox. You can disable the checkbox, but that also means that its value will not be submitted with the form. You can get around this by creating a corresponding hidden field for reach disabled checkbox. That way the values will still be submitted with the form.

As for your JavaScript array, use the same code I gave you in your preivious thread, except look for disabled boxes, rather than unchecked boxes:

if (box.type == "CHECKBOX" && box.disabled)

Consultant, Sima Solutions
I agree. Here's the link:
subject: Setting check box as readonly in JSP?
It's not a secret anymore!