Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Ajax</title>
- <script type="text/javascript">
- var XMLHttpRequestObject = false;
- if (window.XMLHttpRequest)
- {
- XMLHttpRequestObject = new XMLHttpRequest();
- }
- else if (window.ActiveXObject)
- {
- XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
- }
- function pobierzDane(x){
- if(XMLHttpRequestObject)
- {
- var listaOpcji = document.getElementById("listaOpcji");
- XMLHttpRequestObject.open("GET", "zad11"+x+".php");
- listaOpcji.options.length = 0;
- XMLHttpRequestObject.onreadystatechange = function()
- {
- if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
- {
- var odp = XMLHttpRequestObject.responseText.split(" ");
- for(var i=0; i<odp.length; i++)
- {
- listaOpcji.options[i] = new Option(odp[i], odp[i]);
- }
- }
- }
- XMLHttpRequestObject.send(null);
- }
- }
- </script>
- </head>
- <body>
- <div>
- <input type="button" value="Zestaw opcji1" onclick="pobierzDane(a);" />
- <input type="button" value="Zestaw opcji2" onclick="pobierzDane(b);" />
- </div>
- <select id="listaOpcji" method="get">
- </select>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement