Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7906791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:08:17+00:00 2026-06-03T11:08:17+00:00

I have a form that contains 5 drop down lists which are created by

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T11:08:18+00:00Added an answer on June 3, 2026 at 11:08 am

    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!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div that contains a form with two drop down lists in
I have a form in asp.net webpage which contains 2 drop down lists and
Say I have a form that contains a drop-down list populated by values stored
I have a continuous form that contains a drop down box whos control source
I have an HTML form which contains a drop down, a tinyMCE textarea, and
I have a form that contains a GridView control which is databound to an
I have a form MainForm which is a Windows Forms form that contains many
I need to make the program which have one form that contains PNG image
I have a div that contains a student's schedule, and there is a drop-down
I have a form that has a drop down list of song titles. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.