How to disable html:checkbox based on html:radio selection
Shodhan Shah
Greenhorn
Joined: Apr 27, 2006
Posts: 18
posted
0
Guys
I need to disable html:checkbox based on selection of html:radio.
Here is my componenets in JSP. Basically I want to disable ( not allow user to check this checkbox) html:checkbox when html:radio has value "instruction" (second radio button). Any Idea? Thanks in advance.
onklick is used above instead of onclick to get around the JavaRanch filter. Also substitute the actual name of the form-bean name used by this page for "myForm". [ May 25, 2006: Message edited by: Merrill Higginson ]
but I am getting javascript error. 'document.notifyBrowserForm is null or not an object '
Looks Like my form name (notifyBrowserForm) is wrong. What should my form name
My form is html:form. <html:form action="/services/notifyBrowser" focus="msgSessionID" > ( which contains both radio buttons and check box) and it is associated with notifyBrowserForm in struts-config.xml. <struts-config> <form-beans> <form-bean name="notifyBrowserForm" type="com.lehman.enaf.mwgui.NotifyBrowserForm" />
Shodhan Shah
Greenhorn
Joined: Apr 27, 2006
Posts: 18
posted
0
sorry I am getting javascript error 'document.notifyBrowserForm.reply' is null or not an object
Shodhan Shah
Greenhorn
Joined: Apr 27, 2006
Posts: 18
posted
0
Never mind . I got it worked. THANKS FOR ALL YOUR HELP. Instead of "document.notifyBrowserForm.reply.disabled = false" I put only "reply.disabled = false". and it works. I know this is not 100% correct but for now it works.
The above works ( disable/enable check box based on radio button value) only when we click on radio button.
What if we want to disable/enable checkbox based on current value of radio Button ( i.e. not only on onKlick event but based on existing value of radio button)
If I click on 'instruction' radio button , check box is disabled as desired. But when I submit form ,it gets 'enable' mode though radio button value is 'instruction'.
So how to enable /disable checkbox based on current value of radio button ( not only upon onKlick event) .
Thanks in advance.
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
posted
0
If you'll look carefully at my first post, you'll see that I have already shown you some code for doing this:
Note that the above will only work if you are using the EL version of the Struts tags. (See this link for more information) If you're not, you will need to use a scriptlet <%= %> instead. [ May 31, 2006: Message edited by: Merrill Higginson ]