when i click login button it's not redirecting to another php page.it's showing error on page. my code is below.

<html>
<head>
function win()
{
var a=document.getElementById('myusername');
var b=document.getElementById('mypassword');
var temp=a.value;
var temp1=b.value;
window.opener.top.location.href="http://www.careerglitters.com/web_login1.php?vars=" + temp + "&varr=" +temp1;
self.close();
}
</head>
<body>
<form>
<input type="text" name="myusername" style="width: 10em;">
<input type="password" name="mypassword" style="width:10em;">
<input type="button" name="button" value="Login" onClick="win()">
</form>
</body>
</html>

sorry . i mentioned script type also.modification in previous posting.

<html>
<head>
<script type="text/javascript">
function win()
{
var a=document.getElementById('myusername');
var b=document.getElementById('mypassword');
var temp=a.value;
var temp1=b.value;
window.opener.top.location.href="http://www.careerglitters.com/web_login1.php?vars=" + temp + "&varr=" +temp1;
self.close();
}
</script>
</head>
<body>
<form>
<input type="text" name="myusername" style="width: 10em;">
<input type="password" name="mypassword" style="width:10em;">
<input type="button" name="button" value="Login" onClick="win()">
</form>
</body>
</html>

First of all, the input types doesn't have an id. So, getElementById will not work. Secondly, this isn't a popup. So, window.opener will not work. Try window.top.location.href .

When debugging javascript code you could try using

try {
// Do something here
}catch(e){
   // If there is an error then alert
   alert("Error: " + e);
}
This article has been dead for over six months. Start a new discussion instead.