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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vikas251074
    New Member
    • Dec 2007
    • 198

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

    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'.

    Code:
    <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.val ue) is as follows -
    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("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.va lue) is called and the error message is 'Object doesn't support this property or method'.

    Thanks and regards,
    Vikas
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    try the following:

    [CODE=javascript]document.getEle mentById("login ").value = xmlHttp.respons eText;[/CODE]
    instead of using innerHTML ...

    kind regards

    Comment

    • vikas251074
      New Member
      • Dec 2007
      • 198

      #3
      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

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        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

        Comment

        • vikas251074
          New Member
          • Dec 2007
          • 198

          #5
          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

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by vikas251074
            I think error is in line no. 21 where the function 'userid(this.va lue) 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.

            Comment

            • vikas251074
              New Member
              • Dec 2007
              • 198

              #7
              Yes I have done this also, but not getting solution. The error message is same.

              Thanks and regards,
              Vikas

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Have you added the id to the div as suggested earlier?

                Comment

                • vikas251074
                  New Member
                  • Dec 2007
                  • 198

                  #9
                  Yes,
                  I have done that way also

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

                  But with no hope!!!!

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Post the latest version of your code.

                    Comment

                    • vikas251074
                      New Member
                      • Dec 2007
                      • 198

                      #11
                      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>

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        A div doesn't have a value property. Use innerHTML instead.

                        Comment

                        • vikas251074
                          New Member
                          • Dec 2007
                          • 198

                          #13
                          This property is not working. I have modified line no.18 as follows-.

                          document.getEle mentById("login 1").innerHTML=x mlHttp.response Text;}


                          Thanks and regards,
                          Vikas

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #14
                            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
                            [code=javascript]if (xmlHttp.readyS tate == 4) {
                            if (xmlHttp.status == 200) {
                            // now set login1...[/code]

                            Comment

                            • vikas251074
                              New Member
                              • Dec 2007
                              • 198

                              #15
                              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

                              Comment

                              Working...