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

  • Home
  • SEARCH
  • 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 7169049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:54:22+00:00 2026-05-28T14:54:22+00:00

I have got 2 drop down list in my php form. Values in the

  • 0

I have got 2 drop down list in my php form. Values in the drop down list would be retrieved from the database(mysql). I have got the first drop down list running. But now I need to update the 2nd drop down list upon the user’s selection. The value displayed in the 2nd drop down would defer depending on the user’s selection.

How do I update values of another drop down list after a user has selected an option from the first drop down list? I have searched and seen similar question on SO but they aren’t answered. Hope to get some help here. Thanks. Below is my current code I have.

PS. If I were to create a html form, I would need to run the php script upon lauching, without any inputs to populate the first drop down list. How do I so? I’m only aware of how to send request upon inputs; E.g. <input type=submit>

.php

<?php
$conn = mysql_connect("127.0.0.1","root","")
mysql_select_db(MyApp,$conn);


$sql2=("SELECT App.AppName FROM App);               


$result2=mysql_query($sql2); 
echo '<select name="sublist">';
echo '<option value=""></option>';

while ($row2 = mysql_fetch_assoc($result2))
{
    echo '<option value="' . $row2['AppName'] . '">' . $row2['AppName']. '</option>';
}
echo '</select>';                                           
?>
  • 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-05-28T14:54:23+00:00Added an answer on May 28, 2026 at 2:54 pm

    You have two solutions for this.

    1. Do completely in PHP (I do not recommend since, it’s not much user friendly)
    2. Ajax based (More user friendly)

    However to perform both things in good manner you need support of Javascript

    So if I explain you the solution one. Once user change your first dropdown list. You have to POST your page to the same page using onChange() event. Then in your page set the elements for the second dropdown list same as you did for the first dropdown.

    The second solution require AJAX. Once user change the first dropdown you make a AJAX request to a page. In that page you catch the selection user did. And you generate the second dropdown based on that. Here you can use three methods to get the second dropdown or it’s data.

    a. You generate the all the options from that page and send back. Set the innerHTML of the second dropdown.

    b. Get the data as JSON and populate your dropdown based on that.

    c. Get AJAX XML and populate your dropdown based on that.

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

Sidebar

Related Questions

I have a drop down list and would like to remove an option from
i currently have an empty drop down list that I would like to fill
How can I add a data to my drop down list came from database?
We have got loads of options for php + MySQL + Apache combo... Which
I have three drop down list <h:selectOneMenu> , and a <p:dataTable> . I want
I have got a form (php in html or the other way around). Once
I've got a page which will have about ten drop down lists which are
Say, I have got a form which uses the same values as my other
I've got a frustrating issue with Jquery auto-complete. I have UL of drop down
The situation I have is a drop down list and an image on a

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.