/    Sign up×
Community /Pin to ProfileBookmark

Works, but doesn’t work…

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>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gcrowanAug 27.2003 — 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>
Copy linkTweet thisAlerts:
@tacseauthorAug 28.2003 — Thanks. This appears to be it.

tacse
×

Success!

Help @tacse spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...