SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need to only pass url for radio button selected on form

    Hello, I have the following script:

    <script type="text/javascript">

    function OnSubmitForm()

    {

    if(document.myform.operation[0].checked == true)

    {

    document.myform.action ="https://webtrace.etdatacenter.com/webtrace.aspx?accesstype=autologin&cust=id_015&user=lhowe";

    }

    else

    if(document.myform.operation[1].checked == true)

    {

    document.myform.action ="https://carrierconnect.etdatacenter.com/Default.aspx?accesstype=autologin&cust=id_015&user=lhowe";

    }

    return true;

    }

    </script>



    <form name="myform" target="_blank" action="" onsubmit="return OnSubmitForm();">
    <fieldset>
    <legend><font color="#FFFFFF">LOGIN</font></legend>
    username: <input type="text" name="username"/><br />
    password: <input type="password" name="password"/><br />
    <input type="radio" name="operation" value="1" checked><font size="-1">Customer Tracking</font>
    <input type="radio" name="operation" value="2"><font size="-1">Web Booking </font>

    <input type="submit" name="submit" value="submit">
    </fieldset>

    </form>


    Where the value of OnSubmitForm() is chosen and I want the user to be directed to either the first url in the function or the second based on which radio button chosen, but only read in the url and not any of the selections made, i.e. don't pass through the user, password, radio button selected

    If anyone could tell me what needs to be adjusted on the form I would really apppreciate it.


    thanks

  2. #2
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It sounds like all you want to do is send the user to a different page. If that's the case, you don't have to mess with the form's action. You can just change the window's location:

    Code JavaScript:
    function OnSubmitForm() {
        if(document.myform.operation[0].checked == true) {
            window.location ="https://webtrace.etdatacenter.com/webtrace.aspx?accesstype=autologin&cust=id_015&user=lhowe";
        } else if(document.myform.operation[1].checked == true) {
            window.location ="https://carrierconnect.etdatacenter.com/Default.aspx?accesstype=autologin&cust=id_015&user=lhowe";
        }
        return true;
    }
    I'm the web overlord for Graphic Business Systems


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
  •