This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes disable option tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "disable option tag" Watch "disable option tag" New topic
Author

disable option tag

jayanthi choudhary
Greenhorn

Joined: Jun 14, 2006
Posts: 2
I have tried diabling the option collection tag but cant get it . I was able to disable the <html:select> by disable="true" but this attribute is not working for the <option collection.

Please give me a solution for this.

Thanks in advance.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Sorry, jayanthi, you can't disable a single option in a select box. The entire select box is either enabled or disabled.

If you need to make sure a user doesn't select a specific option, you have two choices:

1-Use server-side logic to make sure the offending option is not included in the option list when the page is generated.
2-Use JavaScript on the client-side to remove the option from the list of options if a particular condition exists or user action is taken. This can get tricky, because if the user changes his/her mind, you may have to put the option back again.


Merrill
Consultant, Sima Solutions
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
Disabled is attribute of struts html's option tag. This attribute is not available for options & optionsCollection tag's. The biggest trouble is option disabled attribute is not browser compatible. IE does not support disabled attribute for select element where as Firefox supports it.

If you want to disable the options then you have to use logic:iterate, logic:equal and html: option together to disable certain options.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Thanks, Purushothaman. I learned something new today. I'll have to play around with Firefox's support of disabling a single option.

It's great that Firefox supports it, but the fact that the most popular browser does not support it seems like a pretty big drawback to me. Unless you are writing an intranet application where Firefox is the only browser supported, I wouldn't use it.
[ July 31, 2006: Message edited by: Merrill Higginson ]
 
jQuery in Action, 2nd edition
 
subject: disable option tag
 
Similar Threads
html:link disable
How to disable an option within select dropdown in IE
autocomplete disabled
HFSJ Mock exam 7 Q13 page 338
HashMap, DropDown List, order of values