Kevinito
06-19-2004, 03:50 AM
Hi!
I am busting my head attempting to figure out this code. As you can see, if you type the username "KFoster" and the password "MST3K", you should be directed to another website. I've been through the code several times but to no avail. Here it is . . . (sorry it is heavily commented)
-Many thanks
<html>
<head>
<title>Login Form</title>
</head>
<!--Begin body of HTML document with formatting -->
<body background="../bkgnd.gif">
<H1 align="center"><font color="#000080" face="Verdana">Hidden Valley Vineyards Login Form</H1>
<center><img src="vine.jpg"></center>
<!--Form Name is frmLogin -->
<form method="post" name="frmLogin" action="javascript:void(0)">
<center><table border="0" width="300" cellspacing ="0" cellpadding="1">
<tr>
<!--Create 2 text boxes and assign values -->
<td><font color="#000080" face="Verdana">User Name: </td><td><input type="text" name="txtUserName" size="22"></td><br><br>
</tr>
<tr>
<td><font color="#000080" face="Verdana">Password: </td><td><input type="text" name="txtPassword" size="22"></td> <br><br>
<!-- Create Dropdown list for all departments -->
<tr>
<td><font color="#000080" face="Verdana">Department: </td>
<td><select size="1" name="1stDepartment">
<option value="../administration">Administration</option>
<option value="customer">Customer</option>
<option value="employee">Employee</option>
<option value="finance">Finance</option>
<option value="hr">Human Resources</option>
<option value="it">Information Technology</option>
<option value="management">Management</option>
<option value="manufacturing">Manufacturing</option>
<option value="marketing">Marketing</option>
<option value="webmaster">Webmaster</option>
</select>
</td>
</tr>
</table>
<br><br>
<!--Create 1 button and assign a function(login()) to the button(btnLogin) -->
<input type="button" value="Go to the Department Website" name="btnLogin" onClick="login()">
<!--Create 1 button to clear the screen -->
<input type="reset" value="Clear Form" name="btnClear">
</form>
</center>
</body>
<script language="javascript">
<!-- Create function login() -->
function login(){
<!-- Declare three variables -->
var strUserName, strPassword, strDepartment;
<!-- Assign intPrice to txtPrice textbox -->
strUserName=document.frmLogin.txtUserName.value;
<!-- Assign intTax to txtTax textbox -->
strPassword=document.frmLogin.txtPassword.value;
<!-- Assign intTax to txtTax textbox -->
strDepartment=document.frmLogin.1stDepartment.value;
switch (strUserName){
case "KFoster":
if (strPassword == "MST3K") {
window.location.href = strDepartment + ".htm";
}
else{
window.location.href = "loginFormJS.htm";
}
break;
}
}
</script>
</html>
I am busting my head attempting to figure out this code. As you can see, if you type the username "KFoster" and the password "MST3K", you should be directed to another website. I've been through the code several times but to no avail. Here it is . . . (sorry it is heavily commented)
-Many thanks
<html>
<head>
<title>Login Form</title>
</head>
<!--Begin body of HTML document with formatting -->
<body background="../bkgnd.gif">
<H1 align="center"><font color="#000080" face="Verdana">Hidden Valley Vineyards Login Form</H1>
<center><img src="vine.jpg"></center>
<!--Form Name is frmLogin -->
<form method="post" name="frmLogin" action="javascript:void(0)">
<center><table border="0" width="300" cellspacing ="0" cellpadding="1">
<tr>
<!--Create 2 text boxes and assign values -->
<td><font color="#000080" face="Verdana">User Name: </td><td><input type="text" name="txtUserName" size="22"></td><br><br>
</tr>
<tr>
<td><font color="#000080" face="Verdana">Password: </td><td><input type="text" name="txtPassword" size="22"></td> <br><br>
<!-- Create Dropdown list for all departments -->
<tr>
<td><font color="#000080" face="Verdana">Department: </td>
<td><select size="1" name="1stDepartment">
<option value="../administration">Administration</option>
<option value="customer">Customer</option>
<option value="employee">Employee</option>
<option value="finance">Finance</option>
<option value="hr">Human Resources</option>
<option value="it">Information Technology</option>
<option value="management">Management</option>
<option value="manufacturing">Manufacturing</option>
<option value="marketing">Marketing</option>
<option value="webmaster">Webmaster</option>
</select>
</td>
</tr>
</table>
<br><br>
<!--Create 1 button and assign a function(login()) to the button(btnLogin) -->
<input type="button" value="Go to the Department Website" name="btnLogin" onClick="login()">
<!--Create 1 button to clear the screen -->
<input type="reset" value="Clear Form" name="btnClear">
</form>
</center>
</body>
<script language="javascript">
<!-- Create function login() -->
function login(){
<!-- Declare three variables -->
var strUserName, strPassword, strDepartment;
<!-- Assign intPrice to txtPrice textbox -->
strUserName=document.frmLogin.txtUserName.value;
<!-- Assign intTax to txtTax textbox -->
strPassword=document.frmLogin.txtPassword.value;
<!-- Assign intTax to txtTax textbox -->
strDepartment=document.frmLogin.1stDepartment.value;
switch (strUserName){
case "KFoster":
if (strPassword == "MST3K") {
window.location.href = strDepartment + ".htm";
}
else{
window.location.href = "loginFormJS.htm";
}
break;
}
}
</script>
</html>