Scotfolk.js
By: a guest | Mar 20th, 2010 | Syntax:
JavaScript | Size: 1.09 KB | Hits: 89 | Expires: Never
scotfolk.js
var xmlhttp;
function showGigs() {
xmlhttp = new XMLHttpRequest();
var url="gigs.php?ran="+Math.random(); // Stops cached page being loaded by client
var otypes = new Array();
var stypes = new Array(); // Setup arrays
var options = document.getElementsByTagName('option');
var selects = document.getElementsByTagName('select'); // Store collects and options
var i = 0; //setup integer counter
for (i=0;i<selects.length;i++) { // for each form
stypes[i] = selects[i].name; // find select name
otypes[i] = selects[i].value; // Find option value
url = url+"&"+stypes[i]+"="+otypes[i]; // Add the filter to the end of the url
}
xmlhttp.onreadystatechange=stateChanged // Run stateChanged when ready state changes
xmlhttp.open("GET",url,true); // open a GET request with the generated url and continue execution
xmlhttp.send(null); // and send
}
function stateChanged() // Checks to see if request is completed before displaying result
{
if (xmlhttp.readyState==4) // When ready state is 4
{
document.getElementById("display").innerHTML=xmlhttp.responseText; // Feed data
}
}