Perform function in php based on onChange javascript value passed before performing anything
I have a page (see link below) in which if you type something in the Part_no field, it performs JS function. The JS function does a search thru a db with PHP Mysql and if it finds matching value, it auto populates the other columns. That works fine. However, if it finds nothing, it still performs the function and populates with nothing. That is the flaw. I want it to Do NOTHING if it doesn't find a matching value. (still writing this question.. please hold)
function changeAllProdSelections(str) {
if (str == "") {
//document.getElementById("selections").innerHTML = "";
// location.reload();
return;
} else {
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("selections").innerHTML = this.responseText;
}
};
xmlhttp.open("GET","changeAllProdSelections.php?q="+str,true);
xmlhttp.send();
}
}