Click to See Complete Forum and Search --> : Works, but doesn't work...


tacse
08-27-2003, 04:10 PM
I am fairly new in the JS scene. I am trying to check a ckeckbox "rg" in the form. If the checkbox is not checked post to page1, If the checkbox "rg" is checked – post the form information to a differnet page "page2.asp

It works on IE and NS on a Mac, it works on windows 95 and 98 in IE and NS, works in windows 2000 and xp in NS only. I cannot get this to work for IE in the newer browsers . Any thoughts would be great.

<script language="JavaScript">
<!--
function checkForm( thisform ) {

if (thisform.rg.checked == 1)
{
document.form1.submit(); document.form1.action = "http://www.page2.asp";
return(false);
}
return(true);
}
//-->
</script>



<form method=post action=http://www.pag1.asp onSubmit="return checkForm(this)" id=form1 name=form1>

gcrowan
08-27-2003, 05:17 PM
I would put the function call in the submit button but is not necessary.

<html>
<head>
<title>Untitled</title>
<script language="JavaScript"><!--
function checkForm(f) {

if (f.rg.checked == 1) {
f.action = "http://www.page1.asp";
}else{
f.action = "http://www.page2.asp";
}
}
//-->
</script>
</head>
<body>
<form method="post" action="" id="form1" name="form1" onSubmit="checkForm(this);">
<input type="checkbox" name="rg" value="">
<input type="submit" value="Submit">
</form>

<!--
<form method="post" action="">
<input type="checkbox" name="rg" value="">
<input type="submit" value="Submit" onClick="checkForm(this.form);">
</form>
-->
</body>
</html>

tacse
08-28-2003, 08:54 AM
Thanks. This appears to be it.

tacse