...

View Full Version : javascript form action onsubmit window.location.href



Shaun10
12-26-2007, 01:47 AM
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>

Shaun10
12-26-2007, 02:38 AM
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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum