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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript form action onsubmit window.location.href

    Unable to find the right combination to make the folowing code work, looking to log into C-panal and Webmail via a website based login window.
    Code below

    function login() {
    var url = document.login.url.value;
    var port = document.login.port.value;
    var user = document.login.user.value;
    var pass = document.login.pass.value;
    window.location.href = url+":"+port+"/login/?user="+user+"&pass="+pass
    /*
    The below url works when directly inserted into a browser window
    Unable to find the code to make it work on the window.location.href
    "http://www.myurl.co.uk:2082/login/?user=myusername&pass=mypassword"
    */
    }
    </script>
    </head>
    <body>
    <form name="login" method="post" onSubmit="javascript:login()">
    <table width="150px" border="1px" align="center">
    <tr><td><select name="url"> /*select url's*/
    <option value="http://www.myurl.co.uk">myurl</option>
    <option value="http://www.anotherurl.co.uk">anotherurl</option>
    </select></td></tr>
    <tr><td><select name="port"> /*select ports*/
    <option value="2082">C-Panel</option>
    <option value="2095">Webmail</option>
    </select></td></tr>
    <tr><td>Username:<input type="text" name="user" /></td></tr>
    <tr><td>Password:<input type="password" name="pass" /></td></tr>
    <tr><td><input type="submit" value="Login" name="login" /></td></tr>
    </table>
    </form>

  • #2
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This code below works for Onclick, not sure why it does not work for onSubmit, now i need to find out how secure it is, as i don't want to send unsecure logon details

    <script language="javascript" type="text/javascript">
    function login() {
    var url = document.loginform.url.value;
    var port = document.loginform.port.value;
    var user = document.loginform.user.value;
    var pass = document.loginform.pass.value;
    window.parent.location.href=url+":"+port+"/login/?user="+user+"&pass="+pass;
    }
    </script>
    </head>
    <body>
    <form name="loginform">
    <table width="150px" border="1px" align="center">
    <tr><td><select name="url"> /*select url's*/
    <option value="http://www.myurl.co.uk">myurl</option>
    <option value="http://www.anotherurl.co.uk">anotherurl</option>
    </select></td></tr>
    <tr><td><select name="port"> /*select ports*/
    <option value="2082">C-Panel</option>
    <option value="2095">Webmail</option>
    </select></td></tr>
    <tr><td>Username:<input type="text" name="user" /></td></tr>
    <tr><td>Password:<input type="password" name="pass" /></td></tr>
    <tr><td><input type="button" name="Login" value="Click to login" onClick="login();" />
    </td></tr>
    </table>
    </form>


  •  

    Posting Permissions

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