...

View Full Version : select user destination



zorro
07-17-2003, 01:27 AM
Is there a javascript to select user destination on form submission, based on the selection of a radiobutton.

Example:

If they select "Method of Payment" as "Check", they go to abc.html when they press submit.

If the select "Method of Payment" as "Credit Card", they go to xyz.html when they press submit.

I know this can be done in Perl, but don't know about Javascript.
Thank you.

Carl
07-17-2003, 01:40 AM
Probably best to do with server side :)

Detect what kind, and then redirect to abc.html?somefield=blah&thisfield=hi

I don't think you can change the form action with JScript. :)

zorro
07-17-2003, 03:38 AM
Thanks. That's what I thought, but would be OK if I was wrong.

Someone suggested setDestination, but isn't that VB or C++ or something like that?

Roy Sinclair
07-17-2003, 04:25 PM
Javascript can indeed change the form action.

document.forms['your form name here'].action='your page you want the form to go to here'

jalarie
07-17-2003, 06:53 PM
&nbsp;&nbsp;<form&nbsp;method="post"&nbsp;target="_blank"&nbsp;action=""&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enctype="text/plain"&nbsp;onsubmit="return&nbsp;CheckIt()">
&nbsp;&nbsp;&nbsp;&nbsp;<input&nbsp;type="radio"&nbsp;name="Radio1"&nbsp;value="jalarie@umich.edu"&nbsp;checked="checked"&nbsp;/>&nbsp;Me&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<input&nbsp;type="radio"&nbsp;name="Radio1"&nbsp;value="jalarie@umflint.edu"&nbsp;/>&nbsp;Myself&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<input&nbsp;type="radio"&nbsp;name="Radio1"&nbsp;value="jalarie@flint.umich.edu"&nbsp;/>&nbsp;I
&nbsp;&nbsp;&nbsp;&nbsp;<br&nbsp;/>
&nbsp;&nbsp;&nbsp;&nbsp;<textarea&nbsp;cols="40"&nbsp;rows="5"&nbsp;name="Message"></textarea>
&nbsp;&nbsp;&nbsp;&nbsp;<br&nbsp;/>
&nbsp;&nbsp;&nbsp;&nbsp;<input&nbsp;type="submit"&nbsp;value="&nbsp;Submit&nbsp;"&nbsp;title="&nbsp;Submit&nbsp;"&nbsp;/>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<input&nbsp;type="reset"&nbsp;value="&nbsp;Reset&nbsp;"&nbsp;title="&nbsp;Reset&nbsp;"&nbsp;/>
&nbsp;&nbsp;</form>
&nbsp;&nbsp;<script&nbsp;type="text/javascript">
&nbsp;&nbsp;&nbsp;&nbsp;<!--&nbsp;Hide&nbsp;this&nbsp;code&nbsp;from&nbsp;non-JavaScript&nbsp;browsers
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CheckIt()&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f1=document.forms[0];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;abbreviation
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(ix1=0;&nbsp;ix1<f1.Radio1.length;&nbsp;ix1++)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(f1.Radio1[ix1].checked)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R1V=f1.Radio1[ix1].value;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;checked&nbsp;radio&nbsp;value
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f1.action='mailto:'+R1V;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;true;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;End&nbsp;hiding&nbsp;-->
&nbsp;&nbsp;</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum