Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    select user destination

    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.

  • #2
    New Coder
    Join Date
    Oct 2002
    Location
    Carlifornia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Carl
    Nobody is Perfect, I am Nobody

    CarlSoft | OGSL

  • #3
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Javascript can indeed change the form action.

    document.forms['your form name here'].action='your page you want the form to go to here'
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    627
    Thanks
    1
    Thanked 20 Times in 20 Posts
    &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"&n bsp;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;Re set&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;&nb sp;&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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •