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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #16
    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.

    Comment

    • vikas251074
      New Member
      • Dec 2007
      • 198

      #17
      xmlHttp.respons eText not returning value

      I know the function of xmlHttp.respons eText.
      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'
      Code:
      <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=[B]xmlHttp.responseText[/B];}
      }
      
      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
      Code:
      <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

      Comment

      • vikas251074
        New Member
        • Dec 2007
        • 198

        #18
        Originally posted by acoder
        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?

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #19
          Originally posted by vikas251074
          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.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #20
            Originally posted by vikas251074
            I know the function of xmlHttp.respons eText.
            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?

            Comment

            • vikas251074
              New Member
              • Dec 2007
              • 198

              #21
              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.

              Code:
              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

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #22
                Glad to hear that you managed to solve it. So I guess it was an ASP problem all along.

                Comment

                Working...