Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Ajax</title>
  6. <script type="text/javascript">
  7.  
  8. var XMLHttpRequestObject = false;
  9.  
  10. if (window.XMLHttpRequest)
  11. {
  12. XMLHttpRequestObject = new XMLHttpRequest();
  13. }
  14. else if (window.ActiveXObject)
  15. {
  16. XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  17. }
  18. function pobierzDane(x){
  19. if(XMLHttpRequestObject)
  20. {
  21. var listaOpcji = document.getElementById("listaOpcji");
  22. XMLHttpRequestObject.open("GET", "zad11"+x+".php");
  23. listaOpcji.options.length = 0;
  24. XMLHttpRequestObject.onreadystatechange = function()
  25. {
  26. if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
  27. {
  28. var odp = XMLHttpRequestObject.responseText.split(" ");
  29. for(var i=0; i<odp.length; i++)
  30. {
  31. listaOpcji.options[i] = new Option(odp[i], odp[i]);
  32. }
  33. }
  34. }
  35. XMLHttpRequestObject.send(null);
  36. }
  37. }
  38. </script>
  39. </head>
  40. <body>
  41. <div>
  42. <input type="button" value="Zestaw opcji1" onclick="pobierzDane(a);" />
  43. <input type="button" value="Zestaw opcji2" onclick="pobierzDane(b);" />
  44. </div>
  45. <select id="listaOpcji" method="get">
  46. </select>
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement