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 8253839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:00:44+00:00 2026-06-08T01:00:44+00:00

I am currently working with a Dependable dropdown menu that functions with the help

  • 0

I am currently working with a Dependable dropdown menu that functions with the help of jQuery and PHP. The values are being pulled of MySQL database. Is there away to php echo the selected value of a dependable drop down menu?

EXAMPLE

HTML/PHP

<form action="" method="post">

        <select name="gender" id="gender" class="update">
            <option value="">Select one</option>
            <?php if (!empty($list)) { ?>
                <?php foreach($list as $row) { ?>
                    <option value="<?php echo $row['id']; ?>">
                        <?php echo $row['name']; ?>
                    </option>
                <?php } ?>
            <?php } ?>
        </select>

        <select name="category" id="category" class="update"
            disabled="disabled">
            <option value="">----</option>
        </select>

        <select name="colour" id="colour" class="update"
            disabled="disabled">
            <option value="">----</option>
        </select>

</form>
  • 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-08T01:00:46+00:00Added an answer on June 8, 2026 at 1:00 am

    Please add jquery.js.
    your html code

        <select name="gender" id="gender" class="update">
            <option value="">Select one</option>
            <?php if (!empty($list)) { ?>
                <?php foreach($list as $row) { ?>
                    <option value="<?php echo $row['id']; ?>">
                        <?php echo $row['name']; ?>
                    </option>
                <?php } ?>
            <?php } ?>
        </select>
    
        <select name="category" id="category" class="update" disabled="disabled">
            <option value="">----</option>
        </select>
    
        <select name="colour" id="colour" class="update" disabled="disabled">
            <option value="">----</option>
        </select>
            //jquery code for source list
        <script type="text/javascript">
            $(document).ready(function(){
                $('#gender').change(function() {
                  if ($(this).val()!='') {
                    $("#category").load("postfile.php",{gender_id: $(this).val()});
                    $("#category").removeAttr('disabled');
                  }
                });
                //code on change of sel_source
                $('#category').change(function() {
                  if ($(this).val()!='') {
                    $("#colour").load("postfile.php",{category_id: $(this).val()});
                    $("#colour").removeAttr('disabled');
                  }
    
                });
            });
        </script> 
    
    
    
    //postfile.php
    //your mysql connection other things goes here
    //code for category
    $objDb = new PDO('mysql:host=localhost;dbname=dbname', 'ur_username', 'ur_password');
    if(isset($_REQUEST['gender_id']) && !empty($_REQUEST['gender_id'])) {
    
               $sql = "SELECT * FROM `categories` WHERE `master` = ?";
        $statement = $objDb->prepare($sql);
        $statement->execute(array($_REQUEST['gender_id']));
        $list = $statement->fetchAll(PDO::FETCH_ASSOC);
    
        if(!empty($list)) {
            $output = '<option value="">Select</option>';
            foreach($list as $row) {              
                    $output .= '<option value="'.$row['id'].'">'.$row['name'].'</option>';
            }
        } else {
            $output = '<option value="">Select</option>';
        }
        echo $output;
    } 
    //code for color
    
    if(isset($_REQUEST['category_id']) && !empty($_REQUEST['category_id'])) {
        $sql = "SELECT * FROM `categories` WHERE `master` = ?";
        $statement = $objDb->prepare($sql);
        $statement->execute(array($_REQUEST['category_id']));
        $list = $statement->fetchAll(PDO::FETCH_ASSOC);
         if(!empty($list)) {
            $output = '<option value="">Select</option>';
            foreach($list as $row) {          
                    $output .= '<option value="'.$row['id'].'">'.$row['name'].'</option>';
            }
        } else {
            $output = '<option value="">Select</option>';
        }
        echo $output;
    } 
    

    Hope this will help you.

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

Sidebar

Related Questions

Currently working on a project that is being developed in VS2010. I'm running Windows
Currently working with converting SQLException error messages into messages that are more useful for
Currently working for the first time with JSON and with little experience of jQuery.
Im currently working on a game that uses multi touch to apply zoom to
Am currently working on an application that requires users to submit posts and comments
Am currently working on a site that uses a lot of cfwindow objects and
im currently working on a project that involves listing contacts with a photo and
Im currently working on a project that requires the following. I need to be
I am currently working on a MYSQL project which has a few fairly standard
Im currently working on a c# project that uses another .net library. This library

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.