Advertisement
Guest User

Untitled

a guest
Mar 30th, 2014
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.88 KB | None | 0 0
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4.  
  5. <script>
  6. window.onload = function() {
  7.     loadDivList();
  8. };
  9.  
  10. function loadDivList() {
  11.     var xmlhttp = new XMLHttpRequest(); //Object for handling xmlhttp requests
  12.    
  13.     xmlhttp.onreadystatechange=function() {
  14.       if (xmlhttp.readyState==4 && xmlhttp.status==200) {
  15.         divListContent = "<option value=\"-1\"> Seleccione una division </option>";
  16.         divListContent += "<option value=\"0\"> Equipos sin division </option>";
  17.         divListContent += xmlhttp.responseText;
  18.         document.getElementById("divList").innerHTML = divListContent;
  19.        
  20.       }
  21.     }
  22.  
  23.     xmlhttp.open("GET","getDivList.php",true);
  24.     xmlhttp.send();
  25. }
  26.  
  27. function loadTeamList() {
  28.     var xmlhttp = new XMLHttpRequest(); //Object for handling xmlhttp requests
  29.     var divSelector = document.getElementById("teamList");
  30.     var selectedDiv = divSelector.options[divSelector.selectedIndex].value;
  31.     var teamListContent = document.getElementById("teamList").innerHTML;
  32.    
  33.     if (selectedDiv == -1) {
  34.         document.getElementById("teamList").innerHTML = "<option value=\"-1\"> Seleccione una division </option>";
  35.         return;
  36.     }
  37.    
  38.     xmlhttp.onreadystatechange=function() {
  39.       if (xmlhttp.readyState==4 && xmlhttp.status==200) {
  40.         teamList = "<option value=\"-1\"> Seleccione un equipo </option>";
  41.         teamListContent += xmlhttp.responseText;
  42.         document.getElementById("teamList").innerHTML = teamListContent;
  43.       }
  44.     }
  45.    
  46.     alert("getTeamList.php?q="+selectedDiv);
  47.     xmlhttp.open("GET","getTeamList.php?q="+selectedDiv,true);
  48.     xmlhttp.send();
  49.    
  50. }
  51. </script>
  52.  
  53. </head>
  54. <body>
  55.  
  56. <select name="divList" id="divList" onChange="loadTeamList();">
  57. <option value="-1"> Seleccione una division </option>
  58. </select>
  59.  
  60. <select name="teamList" id="teamList">
  61. <option value="-1"> Seleccione una division </option>
  62. </select>
  63.  
  64. <br>
  65.  
  66. </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement