Why is my code showing that it's not defined while I'm attempting a simple code with data binding?
<!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=utf-8" />
<title>Untitled Document</title>
<object name="login" id="login" classid="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="member.txt"/>
<param name="UseHeader" value="true"/>
<param name="TextQualifier" value=""/>
<param name="FieldDelim" value="|"/>
</object>
<script>
var rs = login.resultset;
function validation()
{
rs.moveFirst();
while(rs.moveNext())
{
if(document.getElementById("txtid")== rs(0) && document.getElementById("txtpass")==rs(1))
{
alert("Login Succeed");
return;
}
}
alert("Email or Password Wrong");
return;
}
</script>
</head>
<body>
<form>
Username: <input type="text" id="txtid" /> <br/>
Password: <input type="text" id="txtpass" /><br/>
<input type="submit" value="game start" id="btnstart" onclick="validation()"/>
</form>
</body>
</html>
The error message states: login is not defined
I am certain that it's defined! I have tried searching for solutions, but found no clue as to what might be wrong in my code :/ Can someone please help?
EDIT:
Updated version of my code looks like this:
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form>
Username: <input type="text" id="txtid" /> <br/>
Password: <input type="text" id="txtpass" /><br/>
<input type="submit" value="game start" id="btnstart" onclick="validation()"/>
</form>
<object name="login" id="login" classid="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="member.txt"/>
<param name="UseHeader" value="true"/>
<param name="TextQualifier" value=""/>
<param name="FieldDelim" value="|"/>
</object>
<script>
var login = document.getElementById('login');
var rs = login.resultset;
function validation()
{
rs.moveFirst();
while(rs.moveNext())
{
if(document.getElementById("txtid")== rs(0) && document.getElementById("txtpass")==rs(1))
{
alert("Login Succeed");
return;
}
}
alert("Email or Password Wrong");
return;
}
</script>
</body>
</html>
After making these updates, I am now encountering the rs is undefined
error when clicking the button. Can anyone tell me what could be going wrong?