i wonder why my code says that it's not defined when i'm trying to do 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: login is not defined
but i know that it's defined ! i have tried to search about this but i got no clue about what's wrong in my code :/ help please?
EDIT:
i've updated my code to something 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>
the next error i got is the rs is undefined
when i'm clicking the button. am i doing something wrong?