Click to See Complete Forum and Search --> : Checkbox validation


Breeze
12-07-2003, 11:48 PM
I want clicking a checkbox to call a function. Only problem is that it also calls the function when you click off the checkbox.


function rushship() {
if (document.form.rush.checked==true);
window.alert("rushship");
}




<input type = reset value=reset>

<input type="checkbox" name="rush" value="yes" onClick="rushship()">rushship

<input type = button value=test onClick="rushship()">


Thanks

skriptor
12-08-2003, 02:26 AM
Hi,
remove the ';' behind the if-statement.

Good luck, skriptor

fredmv
12-08-2003, 05:14 AM
<script type="text/javascript">
//<![CDATA[
function rushship()
{
if(document.forms[0]['rush'].checked == true) alert("rushship");
}
//]]>
</script><form action="#">
<input type="reset" value="Reset" />
<label for="rush">
<input type="checkbox" name="rush" id="rush" value="yes" />rushship
</label>
<input type="button" value="Test" onclick="rushship();" />
</form>