Ajax有5个下拉列表

I have a form that contains 5 drop down lists which are created by PHP querying a MySql database. The lists are being built correctly.

I want the user to be able to select from a list and have it fill in the form at the bottom based on the value selected.

It works find for the 1st list.

Here's the code from list 1

<td width="90">
<p><select size="1" name="D1" onchange="showStudent(this.value);"> 
 <?php while(list($id, $student_id)=mysql_fetch_row($result1)) {
 echo "
<option value=\"".$student_id."\">".$student_id."</option>";
 }
 ?>
 </select></p>
 </td>

Here's the code From list 2

<td>
<p><select size="1" name="D2" onchange=”showStudent(this.value);” >
<?php while(list($id, $student_id)=mysql_fetch_row($result2)) {
echo "
<option value=\"".$student_id."\">".$student_id."</option>";
 }
 ?>
</select></p>
</td>

Here's the javascript code

<script type="text/javascript">
function CreateXmlHttpObject() { //function 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 showStudent(str)
{
//  alert("Made it to show students"+ str);
if (str=="")
{
document.getElementById("student_data").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("student_data").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","editstudent.php?d="+str,true);
xmlhttp.send();
}

</script>

If I select from the 1st list, everything works as it should. If however I select from lists 2-5, nothing. Even if I select from one of them first. I have even tried changing the name of the function to match a specific list name and still only the 1st one works.

What am I missing?

I believe it's because you have the wrong double-quote tags around your onchange in the html for the 2nd list? =”showStudent(this.value);” > should be ="showStudent(this.value);" >

These odd quote tags come often from copy/pasting from word, outlook or other office applications. They are easy to overlook!