Share Pastebin
Guest
Public paste!

Scotfolk.js

By: a guest | Mar 20th, 2010 | Syntax: JavaScript | Size: 1.09 KB | Hits: 89 | Expires: Never
Copy text to clipboard
  1. scotfolk.js
  2.  
  3. var xmlhttp;
  4.  
  5. function showGigs() {
  6. xmlhttp = new XMLHttpRequest();
  7. var url="gigs.php?ran="+Math.random(); // Stops cached page being loaded by client
  8. var otypes = new Array();
  9. var stypes = new Array(); // Setup arrays
  10. var options = document.getElementsByTagName('option');
  11. var selects = document.getElementsByTagName('select'); // Store collects and options
  12.  
  13. var i = 0; //setup integer counter
  14. for (i=0;i<selects.length;i++) { // for each form
  15. stypes[i] = selects[i].name; // find select name
  16. otypes[i] = selects[i].value; // Find option value
  17. url = url+"&"+stypes[i]+"="+otypes[i]; // Add the filter to the end of the url
  18. }
  19. xmlhttp.onreadystatechange=stateChanged  // Run stateChanged when ready state changes
  20. xmlhttp.open("GET",url,true); // open a GET request with the generated url and continue execution
  21. xmlhttp.send(null); // and send
  22. }
  23.  
  24. function stateChanged() // Checks to see if request is completed before displaying result
  25. {
  26. if (xmlhttp.readyState==4) // When ready state is 4
  27. {
  28. document.getElementById("display").innerHTML=xmlhttp.responseText; // Feed data
  29. }
  30. }