1 replies
I have 2 javascript functions that call different data. i need data from each function to display in different divs. when a select is chosen it will load the customers info in one div, notes in the other. if they choose select customer i need it to display the form again. not sure what im doing wrong. i can make it fill out one div but not the other. i have tryed adding both functions to the onchange and it doesnt work. ive tried added the second function to the bottom of the first function and it dont work. i know im missing something stupid. also no clue how to make it display the form if they choose a customer then choose select customer again.

any help would be appreciated

here is the code and divs and select.

functions
function showCustomers(str) {
if (str=="") {
document.getElementById("txtcustomer").innerHTML=" ";
return;
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtcustomer").innerHTML=x mlhttp.responseText;
}
}
xmlhttp.open("GET","customers.php?c="+str,true);
xmlhttp.send();
}

function showNotes(str) {
if (str=="") {
document.getElementById("txtnotes").innerHTML="";
return;
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtnotes").innerHTML=xmlh ttp.responseText;
}
}
xmlhttp.open("GET","notes.php?q="+str,true);
xmlhttp.send();
}

select code
echo '<select name="customers" onchange="showCustomers(this.value);">';
echo '<option value="0">Select Customer</option>';
$queryc = "SELECT * FROM customers ORDER BY lastname";
$resultc = mysql_query($queryc) or die(mysql_error());
while($rowc = mysql_fetch_array($resultc)){
echo '<option value="'.$rowc['id'].'">'.$rowc['lastname'].', '.$rowc['firstname'].'</option>';
}
echo '</select>';

divs
<div id="txtcustomer">FORM HERE</div>
<div id="txtnotes"></div>
#javascript

Trending Topics