[SOLVED] Firing an Ajax Request From PHP generated pulldowns
Posted: Wed May 09, 2012 11:58 am
SOLVED - The problem was in the quotation marks around the onchange call
Not sure exactly which forum to post this in, but since my php seems to be working I thought I'd try here
I have 5 pulldowns which are populated by PHP/MySql queries - the queries work and give me the correct data and here is an example of where I am placing the results
So far so good, I get the right students, now when I make a selection this is the <script> it's supposed to be firing (sorry I used the php tags) didnt see a 'code' tag
I'm not getting any firing of the function, at least it never gets to the alert inside the function.
would someone mind telling me what I'm missing or doing wrong?
TIA
Not sure exactly which forum to post this in, but since my php seems to be working I thought I'd try here
I have 5 pulldowns which are populated by PHP/MySql queries - the queries work and give me the correct data and here is an example of where I am placing the results
Code: Select all
<td width="90">
<form>
<p><select size="1" name="D1" onchange=”showStudents(this.value);”>
<?php while(list($id, $student_id)=mysql_fetch_row($result1)) {
echo "
<option value=\"".$id."\">".$student_id."";
}
?>
</select></p>
</form> </td>
Code: Select all
<script type="text/javascript">
function CreateXmlHttpObject() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();//creates a new ajax object
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");//this is for IE browser
}
catch(e){
try{
req = new ActiveXObject("Msxml2.XMLHTTP");//this is for IE browser
}
catch(e1){
xmlhttp=false;//error creating object
}
}
}
return xmlhttp;
}
function showStudents(str)
{
alert("Made it to show student");
var req=CreateXmlHttpObject();
if(req)
{
req.onreadystatechange=function()
{
if (req.readState=4)(
if(req.status=200){
document.getElementById("student_data").innerHTML=xmlhttp.responseText;
}
else
{alert("there was a problem using XMLHTTP:\n");
}
}
}
req.open("GET","editstudents.php?q="+str,true);
rq.send(null);
}
}
</script>
would someone mind telling me what I'm missing or doing wrong?
TIA