By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,446 Members | 3,120 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,446 IT Pros & Developers. It's quick & easy.

Getting error while entry in userid field/responseText not returning value

vikas251074
100+
P: 198
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'.

Expand|Select|Wrap|Line Numbers
  1. <form name="myform" action="main.asp" method="post">
  2. <div id="content"> 
  3.   <h2 id="pageName">Main Page</h2> 
  4.   <div class="feature"> 
  5.     <h1>Surfing the intranet </h1> 
  6.     <p>
  7.     This is a comprehensive information website on Indian Oil Corporation Limited and specially 
  8.     dedicated to IOCL.
  9.     </p>
  10.   </div> 
  11.   <div class="login" style="position:relative; left:50px"> 
  12.     <table border="1" cellpadding="0" cellspacing="0">
  13.     <tr>
  14.       <td bgcolor="#99FF99"><h3>Employee Login</h3></td>
  15.     </tr>
  16.     <tr>
  17.       <td>
  18.         <table bgcolor="#CCFFCC">
  19.           <tr>
  20.             <td align="right">Login :</td>
  21.             <td><input type="text" name="userid" id="userid" style="width:100px " onblur="userid(this.value);"/></td>
  22.           </tr>
  23.           <tr>
  24.             <td align="right">Password :</td>
  25.             <td><input type="password" name="passwd" style="width:100px "/></td>
  26.           </tr>
  27.         </table>
  28.       </td>
  29.     </tr>
  30.     <tr>
  31.       <td>
  32.         <table bgcolor="#CCFFCC">
  33.           <tr>
  34.             <td><a href="#">Forgot Password?</a></td>
  35.             <td><input type="button" style="width:65px " value="Go" onClick="login();"/></td>
  36.           </tr>
  37.         </table>
  38.       </td>
  39.     </tr>
  40.     </table>
  41.   </div> 
  42. </form>

The description of userid(this.value) is as follows -
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var xmlHttp
  3.  
  4. function userid1(str){
  5.   xmlHttp=GetXmlHttpObject();
  6.   if (xmlHttp==null) {
  7.     alert ("Your browser does not support AJAX!");
  8.     return;
  9.   } 
  10.   var url="checkuser.asp?q="+str+"&sid="+Math.random();
  11.   xmlHttp.onreadystatechange=stateChanged;
  12.   xmlHttp.open("GET",url,true);
  13.   xmlHttp.send(null);
  14. }
  15.  
  16. function stateChanged() { 
  17.   if (xmlHttp.readyState==4) {
  18.     document.getElementById("login").innerHTML=xmlHttp.responseText;}
  19. }
  20.  
  21. function GetXmlHttpObject(){
  22.   var xmlHttp=null;
  23.   try { xmlHttp=new XMLHttpRequest();  }   // Firefox, Opera 8.0+, Safari
  24.   catch (e){ 
  25.     try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}   // Internet Explorer
  26.     catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
  27.   }
  28.   return xmlHttp;
  29. }
  30.  
  31. </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
Jun 20 '08 #1
Share this Question
Share on Google+
21 Replies


gits
Expert Mod 5K+
P: 5,333
try the following:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("login").value = xmlHttp.responseText;
instead of using innerHTML ...

kind regards
Jun 20 '08 #2

vikas251074
100+
P: 198
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
Jun 20 '08 #3

gits
Expert Mod 5K+
P: 5,333
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
Jun 20 '08 #4

vikas251074
100+
P: 198
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
Jun 20 '08 #5

acoder
Expert Mod 15k+
P: 16,027
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.
Jun 20 '08 #6

vikas251074
100+
P: 198
Yes I have done this also, but not getting solution. The error message is same.

Thanks and regards,
Vikas
Jun 20 '08 #7

acoder
Expert Mod 15k+
P: 16,027
Have you added the id to the div as suggested earlier?
Jun 20 '08 #8

vikas251074
100+
P: 198
Yes,
I have done that way also

<div id="login">
and also
<div id="login1">

But with no hope!!!!
Jun 21 '08 #9

acoder
Expert Mod 15k+
P: 16,027
Post the latest version of your code.
Jun 21 '08 #10

vikas251074
100+
P: 198
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var xmlHttp
  3.  
  4. function userid1(str){
  5.   xmlHttp=GetXmlHttpObject();
  6.   if (xmlHttp==null) {
  7.     alert ("Your browser does not support AJAX!");
  8.     return;
  9.   } 
  10.   var url="checkuser.asp?q="+str+"&sid="+Math.random();
  11.   xmlHttp.onreadystatechange=stateChanged;
  12.   xmlHttp.open("GET",url,true);
  13.   xmlHttp.send(null);
  14. }
  15.  
  16. function stateChanged() { 
  17.   if (xmlHttp.readyState==4) {
  18.     document.getElementById("login1").value=xmlHttp.responseText;}
  19. }
  20.  
  21. function GetXmlHttpObject(){
  22.   var xmlHttp=null;
  23.   try { xmlHttp=new XMLHttpRequest();  }   // Firefox, Opera 8.0+, Safari
  24.   catch (e){ 
  25.     try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}   // Internet Explorer
  26.     catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
  27.   }
  28.   return xmlHttp;
  29. }
  30.  
  31. </script>
  32. </head>
  33. <body onload="document.myform.userid1.focus();"> 
  34. <form name="myform" action="main.asp" method="post">
  35. <div id="content"> 
  36.   <h2 id="pageName">Main Page</h2> 
  37.   <div class="feature"> 
  38.     <h1>Surfing the intranet </h1> 
  39.     <p>
  40.     This is a comprehensive information website on XXXXXXXX.
  41.     </p>
  42.   </div> 
  43.   <div id="login1" style="position:relative; left:50px"> 
  44.     <table border="1" cellpadding="0" cellspacing="0">
  45.     <tr>
  46.       <td bgcolor="#99FF99"><h3>Employee Login</h3></td>
  47.     </tr>
  48.     <tr>
  49.       <td>
  50.         <table bgcolor="#CCFFCC">
  51.           <tr>
  52.             <td align="right">Login :</td>
  53.             <td><input type="text" name="userid1" id="userid1" style="width:100px " onchange="userid1(this.value);"/></td>
  54.           </tr>
  55.           <tr>
  56.             <td align="right">Password :</td>
  57.             <td><input type="password" name="passwd" style="width:100px "/></td>
  58.           </tr>
  59.         </table>
  60.       </td>
  61.     </tr>
  62.     <tr>
  63.       <td>
  64.         <table bgcolor="#CCFFCC">
  65.           <tr>
  66.             <td><a href="#">Forgot Password?</a></td>
  67.             <td><input type="button" style="width:65px " value="Go" onclick="login1();"/></td>
  68.           </tr>
  69.         </table>
  70.       </td>
  71.     </tr>
  72.     </table>
  73.   </div> 
  74. <div>
Jun 21 '08 #11

acoder
Expert Mod 15k+
P: 16,027
A div doesn't have a value property. Use innerHTML instead.
Jun 21 '08 #12

vikas251074
100+
P: 198
This property is not working. I have modified line no.18 as follows-.

document.getElementById("login1").innerHTML=xmlHtt p.responseText;}


Thanks and regards,
Vikas
Jun 23 '08 #13

acoder
Expert Mod 15k+
P: 16,027
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
Expand|Select|Wrap|Line Numbers
  1. if (xmlHttp.readyState == 4) {
  2.     if (xmlHttp.status == 200) {
  3.         // now set login1...
Jun 23 '08 #14

vikas251074
100+
P: 198
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
Jun 23 '08 #15

acoder
Expert Mod 15k+
P: 16,027
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.
Jun 23 '08 #16

vikas251074
100+
P: 198
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'
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var xmlHttp
  3.  
  4. function userid2(str){
  5.   xmlHttp=GetXmlHttpObject();
  6.   if (xmlHttp==null) {
  7.     alert ("Your browser does not support AJAX!");
  8.     return;
  9.   } 
  10.   var url="checkuser.asp?q="+str+"&sid="+Math.random();
  11.   xmlHttp.onreadystatechange=stateChanged;
  12.   xmlHttp.open("GET",url,true);
  13.   xmlHttp.send(null);
  14. }
  15.  
  16. function stateChanged() { 
  17.   if (xmlHttp.readyState==4) {
  18.     document.getElementById("message").innerHTML=xmlHttp.responseText;}
  19. }
  20.  
  21. function GetXmlHttpObject(){
  22.   var xmlHttp=null;
  23.   try { xmlHttp=new XMLHttpRequest();  }   // Firefox, Opera 8.0+, Safari
  24.   catch (e){ 
  25.     try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}   // Internet Explorer
  26.     catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
  27.   }
  28.   return xmlHttp;
  29. }
  30.  
  31. </script>
  32. </head>
  33. <body onload="document.myform.userid1.focus();"> 
  34. <form name="myform" action="main.asp" method="post">
  35. <div id="content"> 
  36.   <h2 id="pageName">Main Page</h2> 
  37.   <div class="feature"> 
  38.     <h1>Surfing the intranet </h1> 
  39.     <p>
  40.     This is a comprehensive information website on Indian Oil Corporation Limited and specially 
  41.     dedicated to Barauni Refinery.
  42.     </p>
  43.   </div> 
  44.   <div class="login1" style="position:relative; left:50px"> 
  45.     <table border="1" cellpadding="0" cellspacing="0">
  46.     <tr>
  47.       <td><h3>Employee Login</h3></td>
  48.     </tr>
  49.     <tr>
  50.       <td>
  51.         <table>
  52.           <tr>
  53.             <td align="right">Login :</td>
  54.             <td><input type="text" name="userid1" id="userid1" style="width:100px " onblur="userid2(this.value);"/></td>
  55.           </tr>
  56.           <tr>
  57.             <td align="right">Password :</td>
  58.             <td><input type="password" name="passwd" style="width:100px "/></td>
  59.           </tr>
  60.         </table>
  61.       </td>
  62.     </tr>
  63.     <tr>
  64.       <td>
  65.         <table> 
  66.           <tr>
  67.             <td><a href="#">Forgot Password?</a></td>
  68.             <td><input type="button" style="width:65px " value="Go" onclick="login1();"/></td>
  69.           </tr>
  70.        </table>
  71.       </td>
  72.     </tr>
  73.     <tr>
  74.       <td>
  75.         <table>
  76.           <tr>
  77.             <td><p id="message">Enter user id and password</p></td>
  78.           </tr>
  79.         </table>
  80.       </td>
  81.     </tr>
  82.   </table>
  83.   </div> 
  84. </div>
Code of 'checkuser.asp
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  4. </head>
  5. <body>
  6. <%
  7. response.expires = -1
  8. set conn = server.createobject("ADODB.Connection")
  9. conn.open "Provider=MSDAORA.1; dsn=ipis; password=ipis; user id=ipis; data source=isap2000; persist security into=true"
  10. set rs = server.createobject("ADODB.Recordset")
  11. set rs = conn.execute("select empno from hba_empmast where empno="&request.querystring("q"))
  12. if isnull(rs("empno")) then
  13. %> 
  14. "Invalid User"
  15. <%
  16. end if
  17. %>
  18. </body>
  19. </html>
I think error is in line no. 14.

Thanks and regards,
Vikas
Jun 23 '08 #17

vikas251074
100+
P: 198
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?
Jun 23 '08 #18

acoder
Expert Mod 15k+
P: 16,027
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.
Jun 23 '08 #19

acoder
Expert Mod 15k+
P: 16,027
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?
Jun 23 '08 #20

vikas251074
100+
P: 198
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.

Expand|Select|Wrap|Line Numbers
  1. if rs.eof then
  2. response.write("Invalid User")
  3. else
  4. response.write("Enter user id and password")
  5. end if
This problem is solved.

Thanks and regards,
Vikas
Jun 23 '08 #21

acoder
Expert Mod 15k+
P: 16,027
Glad to hear that you managed to solve it. So I guess it was an ASP problem all along.
Jun 24 '08 #22

Post your reply

Sign in to post your reply or Sign up for a free account.