Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

disable option tag

 
jayanthi choudhary
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic