Hi, there are a few things wrong with your code, it seems like you dont understand the difference between a name and an id. An id is unique, a name is not. You can not retrieve a name with getElementById(). The following code will work in all browsers:
<?php
mysql_connect("localhost", "crispwer_vishal", "vishal@123") or die(mysql_error());
mysql_select_db("crispwer_navy") or die(mysql_error());
$query = "SELECT * FROM depatment";
$result = mysql_query($query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login Form</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
// This function sets the usertype at disabled
function sle()
{
document.getElementById("userDept").disabled=true;
}
// This function decides whether the usertype should be enabled
function ss(niit)
{
var s = niit;
switch(s)
{
case '1':
document.getElementById("userDept").disabled=true;
break
case '2':
document.getElementById("userDept").disabled=true;
break
case '3':
document.getElementById("userDept").disabled=false;
break
default:
document.write("ERROR")
}
}
</script>
</head>
<body onLoad="sle()">
<p> </p>
<form id="loginForm" name="loginForm" method="post" action="userchek.php">
<hr />
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td colspan="3">
<input name="loginType" type="radio" id="1" onclick="ss(this.id); return true;';" value="administrator" />
Administrator|
<input name="loginType" type="radio" id="2" onclick="ss(this.id); return true;" value="storekeeper" />
Store Keeper |
<input name="loginType" type="radio" id="3" onclick="ss(this.id); return true;" value="user" />
User</td>
</tr>
</tr>
<tr>
<td colspan="3">User Department
<select id="userDept" name="userDept">
<option>Select</option>
<?php while($row = mysql_fetch_array($result))
{
echo "<option>$row[Dept_Name]</option>";
}?>
</select>
</td>
</tr>
<tr>
<td width="111"><b>Login</b><td colspan="2"><input name="login" type="text" class="textfield" id="login" /></td>
</tr>
<tr>
<td><b>Password</b></td>
<td colspan="2"><br />
<input name="password" type="password" class="textfield" id="password" />
<br /></td>
</tr>
<tr>
<td><input type="submit" name="Submit" onclick="newwindow();" value=" LOGIN " /></td>
<td width="97"><input type="submit" name="Submit2" value="Forgot Password" /></td>
<td width="80"><input type="submit" name="Submit3" value="New User" /></td>
</tr>
</table>
<hr />
</form>
</body>
</html>
Please note that the names of the selects/checkboxes have changed, so use the following names to retrieve the values:
- $_POST['loginType'] // Admin, storekeeper or user
- $_POST['userDept'] // User department
- $_POST['login'] // Username
- $_POST['password'] // Password
~G