Essentially I have a series of buttons that I'm using to filter a table of data.
I have gotten my first two buttons to work okay with the following:
<button onclick="filter('open');" class="open">Open</button>
<button onclick="filter('closed');"class="closed">Closed</button>
The function looks like this :
function filter(st, location) {
if(st == "") {
document.getElementById("exams").innerHTML = "";
return;
} else {
if(window.XMLHttpRequest) {
var xmlhttp = new XMLHttpRequest();
} else {
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("exams").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET", "ajax.php?st="+st+"&location="+location, true);
}}
In the ajax.php file I am checking for the st parameter to set a variable that I use in my query:
if (isset($_GET["st"])) {
$status = $_GET["st"];
} else {
$status = null;
}
$query = "SELECT examID, `status`, site, first_name, last_name, exam_name, institution FROM exams WHERE status = '{$status}'";
Now I want to pass it another parameter based on another button click to further filter the data. I'm not sure what to put for the parameters though to get this to work.
<button onclick="filter();" class="new-york">New York</button>