469,326 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

DDL keep repeating.. when selected

My code is similar to the one below.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script src="selectuser.js"></script>
  4. </head>
  5. <body><form> 
  6. Select a User:
  7. <select name="users" onchange="showUser(this.value)">
  8. <option value="1">Peter Griffin</option>
  9. <option value="2">Lois Griffin</option>
  10. <option value="3">Glenn Quagmire</option>
  11. <option value="4">Joseph Swanson</option>
  12. </select>
  13. </form><p>
  14. <div id="txtHint"><b>User info will be listed here.</b></div>
  15. </p></body>
  16. </html>
  17.  
  18.  
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...
Mar 26 '08 #1
4 1170
acoder
16,027 Expert Mod 8TB
Can you show the JavaScript code?
Mar 26 '08 #2
Expand|Select|Wrap|Line Numbers
  1. var xmlHttpfunction showUser(str)
  2. xmlHttp=GetXmlHttpObject()
  3. if (xmlHttp==null)
  4.  {
  5.  alert ("Browser does not support HTTP Request")
  6.  return
  7.  }
  8. var url="getuser.php"
  9. url=url+"?q="+str
  10. url=url+"&sid="+Math.random()
  11. xmlHttp.onreadystatechange=stateChanged 
  12. xmlHttp.open("GET",url,true)
  13. xmlHttp.send(null)
  14. }function stateChanged() 
  15. if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  16.  { 
  17.  document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
  18.  } 
  19. }function GetXmlHttpObject()
  20. {
  21. var xmlHttp=null;
  22. try
  23.  {
  24.  // Firefox, Opera 8.0+, Safari
  25.  xmlHttp=new XMLHttpRequest();
  26.  }
  27. catch (e)
  28.  {
  29.  //Internet Explorer
  30.  try
  31.   {
  32.   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  33.   }
  34.  catch (e)
  35.   {
  36.   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  37.   }
  38.  }
  39. return xmlHttp;
  40. }
  41.  
the code is base on an example online
Mar 26 '08 #3
Not too worry.. Thanks anyway
Mar 26 '08 #4
acoder
16,027 Expert Mod 8TB
I guess the error was on the first line where you forgot the newline/semi-colon.

Anyway, glad you got it working.
Mar 27 '08 #5

Post your reply

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

Similar topics

2 posts views Thread by Patrick | last post: by
1 post views Thread by smash2004 | last post: by
reply views Thread by Milkstr | last post: by
2 posts views Thread by pmarisole | last post: by
2 posts views Thread by mj.redfox.mj | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.