I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support this property or method'. - <form name="myform" action="main.asp" method="post">
-
<div id="content">
-
<h2 id="pageName">Main Page</h2>
-
<div class="feature">
-
<h1>Surfing the intranet </h1>
-
<p>
-
This is a comprehensive information website on Indian Oil Corporation Limited and specially
-
dedicated to IOCL.
-
</p>
-
</div>
-
<div class="login" style="position:relative; left:50px">
-
<table border="1" cellpadding="0" cellspacing="0">
-
<tr>
-
<td bgcolor="#99FF99"><h3>Employee Login</h3></td>
-
</tr>
-
<tr>
-
<td>
-
<table bgcolor="#CCFFCC">
-
<tr>
-
<td align="right">Login :</td>
-
<td><input type="text" name="userid" id="userid" style="width:100px " onblur="userid(this.value);"/></td>
-
</tr>
-
<tr>
-
<td align="right">Password :</td>
-
<td><input type="password" name="passwd" style="width:100px "/></td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<table bgcolor="#CCFFCC">
-
<tr>
-
<td><a href="#">Forgot Password?</a></td>
-
<td><input type="button" style="width:65px " value="Go" onClick="login();"/></td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
</table>
-
</div>
-
</form>
The description of userid(this.value) is as follows - - <script type="text/javascript">
-
var xmlHttp
-
-
function userid1(str){
-
xmlHttp=GetXmlHttpObject();
-
if (xmlHttp==null) {
-
alert ("Your browser does not support AJAX!");
-
return;
-
}
-
var url="checkuser.asp?q="+str+"&sid="+Math.random();
-
xmlHttp.onreadystatechange=stateChanged;
-
xmlHttp.open("GET",url,true);
-
xmlHttp.send(null);
-
}
-
-
function stateChanged() {
-
if (xmlHttp.readyState==4) {
-
document.getElementById("login").innerHTML=xmlHttp.responseText;}
-
}
-
-
function GetXmlHttpObject(){
-
var xmlHttp=null;
-
try { xmlHttp=new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari
-
catch (e){
-
try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");} // Internet Explorer
-
catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
-
}
-
return xmlHttp;
-
}
-
-
</script>
I think error is in line no. 21 where the function 'userid(this.value) is called and the error message is 'Object doesn't support this property or method'.
Thanks and regards,
Vikas
21 3628 gits 5,390
Expert Mod 4TB
try the following: - document.getElementById("login").value = xmlHttp.responseText;
instead of using innerHTML ...
kind regards
I have tried this, but get no solution.
I think login is not an <div Id >. It is a <div class=login>
So how this problem will be solved.
Thanks and regards,
Vikas
gits 5,390
Expert Mod 4TB
aaarg ... sorry i just had a quicklook and overlooked that ... the value will not work with divs ... of course.
just give your div an id="login" ... is there any reason why you didn't do that?
kind regards
Yes sir,
I have created main div with an <div id="content">
And all the div created with in this div is defined in
<div class="feature">
<div class="login">
I have done this way. Is it wrong?
Thanks and regads,
Vikas
I think error is in line no. 21 where the function 'userid(this.value) is called and the error message is 'Object doesn't support this property or method'.
Well, it's not surprising if you've called it userid1.
Yes I have done this also, but not getting solution. The error message is same.
Thanks and regards,
Vikas
Have you added the id to the div as suggested earlier?
Yes,
I have done that way also
<div id="login">
and also
<div id="login1">
But with no hope!!!!
Post the latest version of your code.
- <script type="text/javascript">
-
var xmlHttp
-
-
function userid1(str){
-
xmlHttp=GetXmlHttpObject();
-
if (xmlHttp==null) {
-
alert ("Your browser does not support AJAX!");
-
return;
-
}
-
var url="checkuser.asp?q="+str+"&sid="+Math.random();
-
xmlHttp.onreadystatechange=stateChanged;
-
xmlHttp.open("GET",url,true);
-
xmlHttp.send(null);
-
}
-
-
function stateChanged() {
-
if (xmlHttp.readyState==4) {
-
document.getElementById("login1").value=xmlHttp.responseText;}
-
}
-
-
function GetXmlHttpObject(){
-
var xmlHttp=null;
-
try { xmlHttp=new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari
-
catch (e){
-
try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");} // Internet Explorer
-
catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
-
}
-
return xmlHttp;
-
}
-
-
</script>
-
</head>
-
<body onload="document.myform.userid1.focus();">
-
<form name="myform" action="main.asp" method="post">
-
<div id="content">
-
<h2 id="pageName">Main Page</h2>
-
<div class="feature">
-
<h1>Surfing the intranet </h1>
-
<p>
-
This is a comprehensive information website on XXXXXXXX.
-
</p>
-
</div>
-
<div id="login1" style="position:relative; left:50px">
-
<table border="1" cellpadding="0" cellspacing="0">
-
<tr>
-
<td bgcolor="#99FF99"><h3>Employee Login</h3></td>
-
</tr>
-
<tr>
-
<td>
-
<table bgcolor="#CCFFCC">
-
<tr>
-
<td align="right">Login :</td>
-
<td><input type="text" name="userid1" id="userid1" style="width:100px " onchange="userid1(this.value);"/></td>
-
</tr>
-
<tr>
-
<td align="right">Password :</td>
-
<td><input type="password" name="passwd" style="width:100px "/></td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<table bgcolor="#CCFFCC">
-
<tr>
-
<td><a href="#">Forgot Password?</a></td>
-
<td><input type="button" style="width:65px " value="Go" onclick="login1();"/></td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
</table>
-
</div>
-
<div>
A div doesn't have a value property. Use innerHTML instead.
This property is not working. I have modified line no.18 as follows-.
document.getElementById("login1").innerHTML=xmlHtt p.responseText;}
Thanks and regards,
Vikas
Are you still getting the same error?
What's supposed to be output from the ASP file?
You should add a check for the status too - if (xmlHttp.readyState == 4) {
-
if (xmlHttp.status == 200) {
-
// now set login1...
Stop this thread sir.
I have modified the programme. Now I will start new thread now because this thread I think is useless.
Thanks and regards
Vikas
No, not necessarily. There are some things in here which someone would find useful. If it's still the same problem, and you haven't solved it, I suggest you continue in this thread rather than start a new one.
I know the function of xmlHttp.responseText.
But this is not returning any value. I want to check the userid from table and if not found then it should return "Invalid User" in <p id='message'> as soon as cursor moves to next field. Code of 'main.asp' - <script type="text/javascript">
-
var xmlHttp
-
-
function userid2(str){
-
xmlHttp=GetXmlHttpObject();
-
if (xmlHttp==null) {
-
alert ("Your browser does not support AJAX!");
-
return;
-
}
-
var url="checkuser.asp?q="+str+"&sid="+Math.random();
-
xmlHttp.onreadystatechange=stateChanged;
-
xmlHttp.open("GET",url,true);
-
xmlHttp.send(null);
-
}
-
-
function stateChanged() {
-
if (xmlHttp.readyState==4) {
-
document.getElementById("message").innerHTML=xmlHttp.responseText;}
-
}
-
-
function GetXmlHttpObject(){
-
var xmlHttp=null;
-
try { xmlHttp=new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari
-
catch (e){
-
try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");} // Internet Explorer
-
catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
-
}
-
return xmlHttp;
-
}
-
-
</script>
-
</head>
-
<body onload="document.myform.userid1.focus();">
-
<form name="myform" action="main.asp" method="post">
-
<div id="content">
-
<h2 id="pageName">Main Page</h2>
-
<div class="feature">
-
<h1>Surfing the intranet </h1>
-
<p>
-
This is a comprehensive information website on Indian Oil Corporation Limited and specially
-
dedicated to Barauni Refinery.
-
</p>
-
</div>
-
<div class="login1" style="position:relative; left:50px">
-
<table border="1" cellpadding="0" cellspacing="0">
-
<tr>
-
<td><h3>Employee Login</h3></td>
-
</tr>
-
<tr>
-
<td>
-
<table>
-
<tr>
-
<td align="right">Login :</td>
-
<td><input type="text" name="userid1" id="userid1" style="width:100px " onblur="userid2(this.value);"/></td>
-
</tr>
-
<tr>
-
<td align="right">Password :</td>
-
<td><input type="password" name="passwd" style="width:100px "/></td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<table>
-
<tr>
-
<td><a href="#">Forgot Password?</a></td>
-
<td><input type="button" style="width:65px " value="Go" onclick="login1();"/></td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td>
-
<table>
-
<tr>
-
<td><p id="message">Enter user id and password</p></td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
</table>
-
</div>
-
</div>
Code of 'checkuser.asp - <html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-
</head>
-
<body>
-
<%
-
response.expires = -1
-
set conn = server.createobject("ADODB.Connection")
-
conn.open "Provider=MSDAORA.1; dsn=ipis; password=ipis; user id=ipis; data source=isap2000; persist security into=true"
-
set rs = server.createobject("ADODB.Recordset")
-
set rs = conn.execute("select empno from hba_empmast where empno="&request.querystring("q"))
-
if isnull(rs("empno")) then
-
%>
-
"Invalid User"
-
<%
-
end if
-
%>
-
</body>
-
</html>
I think error is in line no. 14.
Thanks and regards,
Vikas
No, not necessarily. There are some things in here which someone would find useful. If it's still the same problem, and you haven't solved it, I suggest you continue in this thread rather than start a new one.
Oh this way, I am sorry sir. Really feel sorry. I have already started new thread. What to do now?
Oh this way, I am sorry sir. Really feel sorry. I have already started new thread. What to do now?
No worries. I've merged the threads.
I know the function of xmlHttp.responseText.
But this is not returning any value. I want to check the userid from table and if not found then it should return "Invalid User" in <p id='message'> as soon as cursor moves to next field.
This code looks better already (you're not replacing the div that contains the login field). You can continue using onchange, though onblur is not too bad in this case. The first thing to check is that the ASP file outputs the correct info. Type the checkuser.asp URL directly into the address bar and test it. What does it output?
OK Sir, Thanks
I got the solution.
I changed the line no. 12 - 16 as following as per the suggestion given by you to check the checkuser.asp directly on address bar. - if rs.eof then
-
response.write("Invalid User")
-
else
-
response.write("Enter user id and password")
-
end if
This problem is solved.
Thanks and regards,
Vikas
Glad to hear that you managed to solve it. So I guess it was an ASP problem all along.
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
4 posts
views
Thread by Dinçer |
last post: by
|
11 posts
views
Thread by David Messner |
last post: by
|
2 posts
views
Thread by Alex Wisnoski |
last post: by
|
11 posts
views
Thread by suzy |
last post: by
|
7 posts
views
Thread by p |
last post: by
|
1 post
views
Thread by C.Joseph Drayton |
last post: by
|
6 posts
views
Thread by MLH |
last post: by
| | | | | | | | | | | | |