Changing the action field of a form tag
If you want to have one form but have it jump to different pages based off of what button a user clicks on, you can use the following example to change the form.action value.
Example HTML/CFML code:
Code:
<html>
<head>
<!--- Set up the javascript to change the action url --->
<script language="Javascript">
function SetURL(site)
{
if (site == '1') document.myform.action='http://www.allaire.com/';
if (site == '2') document.myform.action='http://www.allaire.com/developer/gallery/index.cfm?objectID=6800';
document.myform.submit();
}
</script>
</head>
<body>
<!--- No action field specified, will default to load the same document --->
<center>
<form name="myform" method="get">
<input type="Button" value="Allaire's Homepage" onClick="SetURL('1')"><br><br>
<input type="Button" value="Tag Gallery" onClick="SetURL('2')"><br>
</form>
</center>
</body>