You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "yuensunlam@yahoo.com" <yu...@yahoo.com> on 2003/11/18 18:01:25 UTC

reacting to changes on the checkbox

I wonder if there is a struts way for reacting to
changes on the checkbox and making changes to other
controls as a result. What I would like to happen is
to disable a submit button when no checkbox is
selected, and enable it when only one checkbox is
selected, disable it again if more than one checkbox
are selected. Can anybody show me a example code?

Thanks a bunch!


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


How to identify submit button in JSP

Posted by "yuensunlam@yahoo.com" <yu...@yahoo.com>.
Hi,

I am new to struts, now I have trouble figuring this
out. I do need to have this done, please help!

My problem is the submit button didn't react to
changes on checkbox, is that because I didn't identify
the button correctly or anything else I did wrong? My
jsp code is like the following: (if I add
'disabled="true"' in submit, the button will always be
disabled). 
 
<SCRIPT LANGUAGE="JavaScript">
function Disable() {
frm=document.forms[form1]
if(frm.ids.checked)
{frm.modify.disabled=false}
else {frm.modify.disabled=true}
}
</SCRIPT> 

<html:form 
    action="/Myaction"
    name="form1"
    type="MyformType">

<input type="submit" name="add" value="Add"/>
<input type="submit" name="modify" value="Modify"/>
<input type="submit" name="delete" value="Delete"/>

<%
 while (iterator.hasNext()) 
  {
    String v1=...;
%>
<input type="checkbox" name="ids" value="v1"       
onClick="Disable();"/>something
<%
   }
%>

What I eventually want to do is to disable this
'modify' button when no checkbox or more than one are
selected. In other word, only enable it when only one
checkbox is selected, this is just the first step, but
it's not working.

Thanks in advance!

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org