SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 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,

    CanTaz
    Last edited by CanTaz; Oct 9, 2007 at 16:06. Reason: forgot a couple of lines

  2. #2
    SitePoint Wizard gRoberts's Avatar
    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";
    }


  3. #3
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I will give that a try.

    thanks.
    CanTaz


Bookmarks

Posting Permissions

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