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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:10:47+00:00 2026-06-10T18:10:47+00:00

I have the following code select box div: Make:<br> <select name=Make> <option value =

  • 0

I have the following code select box div:

Make:<br> 
        <select name="Make">
        <option value = "Toyota">Toyota</option>
        <option value = "Honda">Honda</option>
    </select>


<div id="side_model">           
        Model:<br> 
        <select name="Model">
        <PHP CODE THAT SEARCHES DATABASE FOR ALL MODELS AVAILABLE AND LIST THEM AS OPTIONS ?>
    </select>
</div>

And the following Jquery:

<script>
jQuery(document).ready(function($){
    $('#Make').change(function() {
        $.get('dropdown.php',{make: $(this).val() },function(d){
            $('#side_model').html(d);
        });
    });
});
</script>

This is a very simplified version of my code but what Im doing is, once the make is chosen I query the database in dropwdown php and get all models of that make and then simply populate the list

My dropdown.php looks something like this:

Model:<br> 
            <select name="Model">
            <PHP CODE THAT SEARCHES DATABASE FOR ALL MODELS THAT MATCH THE MAKE SELLECTED AND LIST THEM AS OPTIONS ?>
        </select>

Ok so the code pretty much works the way its intended too except for one detail.

Instead of the jQuery replacing the div with the contentes of dropdown.php it is just adding that extra select box on top of it.

How do I get the jQuery code to replace the model select box with the dynamicaly genereated content?

  • 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-10T18:10:49+00:00Added an answer on June 10, 2026 at 6:10 pm

    It may make more sense to use jQuery’s .replaceWith() function (documentation here):

    First, add an ID to your select element

    <div id="side_model">           
        Model:<br> 
        <select id="Model" name="Model">
            <option value='0'>----</option>
        </select>
    </div>
    

    Then replace it with the return value from the $.get():

    jQuery(document).ready(function($){
    
    $('#Make').change(function() {
            $.get('dropdown.php',{make: $(this).val() },function(d){
                $('#Model').replaceWith(d);
            });
        });
    });
    

    Now all you need to do in the background is to generate the select in its entirety (including the open/close <select> tags).

    UPDATE

    I just noticed you’re calling $("#Make").change() but you never give any of your elements an ID set to “Make”. Add the ID attribute to your select where name="Make":

    Make:<br> 
        <select id="Make" name="Make">
            <option value = "Toyota">Toyota</option>
            <option value = "Honda">Honda</option>
        </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code <select id=practice_id name=practice column=practice style=width: 200px> <option value=>Default</option> <option
I have the following code in html: <select> <option text=item9 value=9></option> <option text=item10 value=10></option>
I currently have a HTML select box like below. <select name=item_1> <option value=0>Choose one...</option>
I have the following code on a view: @using (Html.BeginForm()) { <div class=select-box form>
I have the following in the code : $form['location'] = array( '#value' => '<select
I have a small html select box with the value values as options <div
I have the following code: <table id=box-table-a class=tablesorter> <thead> <tr> <th scope=col>B-House/Dorm Name</th> <th
I have the following code which uses JavaScript to select a text box when
All, I have the following bit of HTML code for a select box: <select
I have the following snippet of a HTML select box: <select id=Obj_cboscreen class=menubarselect name=page>

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.