DDL keep repeating.. when selected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • princelindie
    New Member
    • Feb 2008
    • 28

    DDL keep repeating.. when selected

    My code is similar to the one below.

    Code:
    <html>
    <head>
    <script src="selectuser.js"></script>
    </head>
    <body><form> 
    Select a User:
    <select name="users" onchange="showUser(this.value)">
    <option value="1">Peter Griffin</option>
    <option value="2">Lois Griffin</option>
    <option value="3">Glenn Quagmire</option>
    <option value="4">Joseph Swanson</option>
    </select>
    </form><p>
    <div id="txtHint"><b>User info will be listed here.</b></div>
    </p></body>
    </html>
    Each time i select something output the result and also show a new DDL and option.. So i having several DDL apparing one at a time when i select an option in the DDL.
    Please help...
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Can you show the JavaScript code?

    Comment

    • princelindie
      New Member
      • Feb 2008
      • 28

      #3
      Code:
      var xmlHttpfunction showUser(str)
      { 
      xmlHttp=GetXmlHttpObject()
      if (xmlHttp==null)
       {
       alert ("Browser does not support HTTP Request")
       return
       }
      var url="getuser.php"
      url=url+"?q="+str
      url=url+"&sid="+Math.random()
      xmlHttp.onreadystatechange=stateChanged 
      xmlHttp.open("GET",url,true)
      xmlHttp.send(null)
      }function stateChanged() 
      { 
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
       { 
       document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
       } 
      }function GetXmlHttpObject()
      {
      var xmlHttp=null;
      try
       {
       // Firefox, Opera 8.0+, Safari
       xmlHttp=new XMLHttpRequest();
       }
      catch (e)
       {
       //Internet Explorer
       try
        {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
       catch (e)
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
       }
      return xmlHttp;
      }
      the code is base on an example online

      Comment

      • princelindie
        New Member
        • Feb 2008
        • 28

        #4
        Not too worry.. Thanks anyway

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          I guess the error was on the first line where you forgot the newline/semi-colon.

          Anyway, glad you got it working.

          Comment

          Working...