resetting checkboxes to cleared

liunx

Guest
I am making a simple checklist using checkboxes. How can i make it so that once I am done, i can rest all the boxes to cleared for the next call?<br />
<br />
Code follows:<br />
<br />
<html><br />
<head><br />
<title>Power Tools Manual reinstall</title><br />
</head><br />
<body><br />
<br />
<form><br />
Steps for Power Tools Manual reinstalls <br /><br /><br />
<input type="checkbox" name="closeapps"> Close out of all applications, leave qwest/tunnel <br />
<br />
running. <br /><br />
<input type="checkbox" name="autorun"> Close Auto run. <br /><br />
<input type="checkbox" name="ptools"> Change to the ptools directory. <br /><br />
<input type="checkbox" name="setup"> Run Setup.exe <br /><br />
<input type="checkbox" name="update"> Run update.exe <br /><br />
</form><br />
<br />
<br />
</html><br />
</body><br />
<br />
Thanks,<br />
Clayton<br />
<br />
<edit> I snipped the list as I didn't think you needed all 20+ steps. </edit><!--content-->It should just clear itself once you refresh the page. (Sometimes it won't because of the cookie.....)<br />
<br />
Otherwise, I would start searching online for HTML form help. You might be able to find a tag that will help you!<br />
<br />
You could try <!-- m --><a class="postlink" href="http://www.webmonkey.com">http://www.webmonkey.com</a><!-- m -->! like this?<br />
<br />
<script type="text/javascript"><br />
//<![CDATA[<br />
function clearchk() {<br />
var f = document.forms[0];<br />
for(i=0; i<f.elements.length; i++) {<br />
if(f.type == "checkbox") {<br />
f.checked = false;<br />
}<br />
}<br />
}<br />
//]]><br />
</script><br />
... ... ...<br />
<form action="#"><br />
<div><br />
<input type="checkbox" /> <br /><br />
<input type="checkbox" /> <br /><br />
<input type="checkbox" /> <br /><br />
<input type="checkbox" /> <br /><br />
<br />
<input type="button" value="Clear Checkboxes" onclick="clearchk();" /><br />
</div><br />
</form><!--content-->If the only kind of elements you have in your form are checkboxes...<input type="reset" /><!--content-->yep, only checkboxes are there.<!--content-->This realy is a javascript question - <br />
Put this under the body tags -<br />
<br />
<script language="javascript"><br />
function uncheck() {<br />
document.frm.autorun.checked="false";<br />
document.frm.ptools.checked="false";<br />
document.frm.setup.checked="false";<br />
document.frm.update.checked="false";<br />
}<br />
</script><br />
<br />
<br />
<br />
at the end change the submit button to this :<br />
<br />
<input type="submit" onClick="uncheck()"><br />
<br />
You need to call you form - <form name="frm"><br />
That should do it:cool:<!--content-->I think you should take Freds advice and use a reset form element.<br />
<br />
<br />
<nput type="reset" value="Reset Form" /><br />
<br />
<br />
This will eliminate the need for JS.<!--content-->Originally posted by chriz <br />
That should do it Actually, it will not; boolean values should not have quotes around them and moreover, JavaScript is not required for the task at hand and thus should not be used when there are more practical solutions available.<!--content-->Fred's did the trick for me. Thanks for all the responses.<!--content-->Originally posted by fredmv <br />
Actually, it will not; boolean values should not have quotes around them and moreover, JavaScript is not required for the task at hand and thus should not be used when there are more practical solutions available. <br />
Yes, I assumed that there were other things in the form besides checkboxes. Figures I'd try to complicate things. :D<!--content-->
 
Back
Top