By Will Bontrager
2003-09-03
Reader Rating: The Complete Example
With the above mentions, the example code should make sense to you. If it doesn't, send a private note to me at the email address following the article. I'll try to answer your questions.
<script type="text/javascript" language="JavaScript">
<!-- Copyright 2003 Bontrager Connection, LLC
// See article "Changing Form Action URLs On-The-Fly" linked
// from URL http://willmaster.com/possibilities/archives
// for more information about how to use this code.
function ActionDeterminator()
{
if(document.myform.reason[0].checked == true) {
document.myform.action = '/cgi-bin/mf1.cgi';
}
if(document.myform.reason[1].checked == true) {
document.myform.action = '/cgi-bin/mf2.cgi';
document.myform.method = 'get';
}
if(document.myform.reason[2].checked == true) {
document.myform.action = 'http://yahoo.com';
}
return true;
}
// -->
</script>
<form name="myform" method="post" action="/cgi-bin/mf.cgi">
Name: <input type="text" name="a name" size="22"><br>
Email: <input type="text" name="email"size="22"><br>
Reason:<br>
<input type="radio" name="reason">I have a Hot Tip!<br>
<input type="radio" name="reason">I saw a Cool Site!<br>
<input type="radio" name="reason">Get me outta here!<br>
Type comment here:<br>
<textarea name="comments" cols="27" rows="6">
</textarea><br><br>
<input
type="submit"
value="Send It!"
onClick="return ActionDeterminator();">
</form>