SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Oct 9, 2007, 17:05 #1
- Join Date
- Oct 2007
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Directing submit button to different pages
Hi
I need some javascript for a form that will send a user to a different page based on the radio button selected. For example if they select the radio button mortgages then they will go to the mortgage page after clicking the submit button or fiance page if they select the finance radio button.
Here is what I have so far:
<SCRIPT Language="JavaScript">
function verifty(){
if (document.form.mortgage.value=="1"){
get "http://www.ecaledonhills.com/mortgage.html"
if(document.form.finance.value=="1")
get "http://www.ecaledonhills.com/finance.html"
}
</SCRIPT>
</head>
<body>
<table width="261" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="261" height="321" valign="top"><form id="form" name="form" method="GET" action="">
<p align="right">Enter First Name:
<input name="Name" type="text" id="Name" size="25" />
</p>
<p>
<label>
<div align="right">
<div align="left">Email Address:
<input name="email" type="text" id="email" />
<br />
<br />
Mortgage
<input name="mortgage" type="radio" value="radiobutton" />
Finance
<input name="finance" type="radio" value="radiobutton" />
<br />
<br />
<input type="submit" name="Submit" value="Submit" />
</div>
</form></td>
</tr>
</table>
</body>
</html>
All help appreciated.
Thanks,
CanTazLast edited by CanTaz; Oct 9, 2007 at 17:06. Reason: forgot a couple of lines
-
Oct 10, 2007, 02:28 #2
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
IIRC you can just change the action of the form. You may need to reference the form via getElementById instead, and if form.action doesn't work, you may need to set the action attribute via form.setAttribute('action','newurl');
Code:if (document.form.mortgage.value=="1"){ document.form.action = "http://www.ecaledonhills.com/mortgage.html"; if(document.form.finance.value=="1") document.form.action = "http://www.ecaledonhills.com/finance.html"; }
-
Oct 10, 2007, 11:14 #3
- Join Date
- Oct 2007
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok, I will give that a try.
thanks.
CanTaz
Bookmarks