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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:59:02+00:00 2026-06-13T22:59:02+00:00

I have quite a complex problem that I cannot seem to solve. I have

  • 0

I have quite a complex problem that I cannot seem to solve.

I have an Input text box field that populates a select list, when the user inputs a certain ‘term’ in the textbox.

For example:

– If a user inputs the word ‘Mercedes’ in the text box, the select list will be populated with ‘A-class’, ‘B-class’, ‘C-class’, ‘S-class’
– If they enter ‘Audi’ in the text box, the select list is populated with ‘A4’, ‘A5’, ‘A6’ etc.

This so far behaves the way in which I intended it to. However, I would like to create a <div> below that is dynamically populated with the corresponding selected vehicle’s accessories, when a user selects a model from the the select list.

Here is the code I have so far:

HTML

<div>
Manufacturer:<input type="text" id="car_manufacturer"/>
Model: <select id="car_model"></select>
</div>

<p>Vehicle Model Accessories:</p>
<div id="model_accessories">
<!--- Here is a list of the selected vehicle model's accessories. It will change when the model selection changes ------> 
</div>

Javascript

vehicleModels = {
   "Mercedes": ["A-class", "B-class", "C-class", "S-class", "SLK", "ML", ],
   "Audi": ["A3", "A4", "A5", "A6", "A7", "A8", ],
   "BMW": ["120", "320", "330", "520", "635", "745", ]
}

This function takes the value in the textbox and checks if it is defined in the object above. If it is, the corresponding vehicle models are appended to the select list.

    $('#car_manufacturer').change(function() {
            if(vehicleModels[$(this).val()]) { 
                $.each(vehicleModels[$(this).val()], function() { 
                    $('#car_model').append('<option>' + this + '</option>');
                 });
            } 
});​

Here is where the problem begins!How can I now populate the model accessories <div> with the corresponding selected model’s accessories? Here is how the car accessories are being stored at the moment.

mercedes_accessories = ["Xenons", "Adaptive cruise control", "sunroof"];
bmw_accessories = ["Start/stop", "heated seats", "Leather trim"];
audi_accessories = ["Electric seats", "B&O Sound System", "Leather trim",];

Any help would be greatly appreciated. I’m sorry if the question is a bit vague, it’s quite difficult to explain. Thankyou!

  • 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-13T22:59:03+00:00Added an answer on June 13, 2026 at 10:59 pm

    I’d do something like this :

    var vehicleModels = {
           mercedes: ["A-class", "B-class", "C-class", "S-class", "SLK", "ML", ],
           audi: ["A3", "A4", "A5", "A6", "A7", "A8", ],
           bmw: ["120", "320", "330", "520", "635", "745", ]
        },
        vehicleAcc = {
            a3 : ["Xenons", "Adaptive cruise control", "sunroof"],
            a4 : ["Xenons", "Adaptive cruise control", "sunroof"],
            a6 : ["Xenons", "Adaptive cruise control", "sunroof"]
        };
    
    
    $('#car_manufacturer').on('change', function() {
        if(this.value.toLowerCase() in vehicleModels) { 
            $.each(vehicleModels[this.value.toLowerCase()], function(i,e) { 
                $('#car_model').append('<option>'+e+'</option>');
            });
        }
    });
    
    $('#car_model').on('change', function() {
        if (this.value.toLowerCase() in vehicleAcc) {
            $.each(vehicleAcc[this.value.toLowerCase()], function(i,e) {
                $('#car_model_acc').append('<option>'+e+'</option>');
            });
        }
    });
    

    FIDDLE

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

Sidebar

Related Questions

I have a quite complex multi-join TSQL SELECT query that runs for about 8
I have quite a complex piece of code (JQuery and HTML5 Web SQL) that
I have a script that works great. It is quite complex and does numerous
I have quite a complex MySQL query with a problem but I have narrowed
I've been trying to solve a slow trigger problem and now that I have
I have a quite complex class hierarchy in which the classes are cross-like depending
I hope I will find a help here. I have a quite complex MVC
I have quite a problem concerning the use of relational database concepts in Delphi
I have quite big document in html format that generated from Microsoft Word. It
For the problem I have: a) An ordered list of points b) A list

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.