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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:35:20+00:00 2026-06-11T05:35:20+00:00

I have a cascading dropdown with jQuery which is using PHP to retrieve its

  • 0

I have a cascading dropdown with jQuery which is using PHP to retrieve its values. I am trying to nail it so that it works in all situations. Basically it should do the following:

  • Populate child when parent is selected
  • Parent is sticky so if the page is refreshed child should again auto
    populate based on the parent value in the $_POST array.
  • If possible I would also like child to be sticky so that the
    child would also be selected and not just re-populated when the page
    is reloaded.

Here is what I have so far:

$("#parent_id").change(function() {
    $("#child_id").html("<option value=\"\">-- Select One --</option>");
    var p_id = $(this).val();
    if(p_id != 0) {
        $.getJSON('./php/includes/child_web_service.php?p_id=' + p_id,function(data) {   
            $.each(data, function() {
                $("#child_id").append($("<option></option>").val(this['child_id_key']).html(this['child_name']));
            });
        });
    }
});

<?php
if(isset($_POST['parent_id']) && $_POST['parent_id'] != ""){
echo "$(\"#parent_id\").val(" . $_POST['parent_id'] . ").trigger('change');";
}
?>

Any suggestions on making this more robust would be appreciated.
Thanks

  • 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-11T05:35:22+00:00Added an answer on June 11, 2026 at 5:35 am

    Here are a few suggestions:

    • Use bind and trigger to populate child when parent is selected
    • Store $_POST in a variable to make the parent sticky, and use a ctype to validate it
    • Use a fragment identifier to append child to URL, then bind event to read the value and make child sticky on reload
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a cascading drop down list using JQuery. The code that I
I am trying to setup a cascading dropdown with python/jquery/ajax. The first dropdown is
So I have a cascading dropdown of sorts, but using List Boxes. When an
I have a few cascading dropdowns on the bottom of my php page. Each
I'm trying to create some cascading drop downs. I have my States loading via
I have cascading drop down lists in a .net mvc view and am using
I have a problem in my jquery code. I want to make a cascading
I'm planning to create a cascading dropdown list of Country--> State/Province--->Zip code using geonames.
I have a number of cascading drop down boxes that allow users to filter
I'm using jQuery to dynamically populate some cascading drop-down controls when a page loads.

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.