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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:27:49+00:00 2026-05-30T17:27:49+00:00

I have a form where if the user changes the platform (operating system), an

  • 0

I have a form where if the user changes the platform (operating system), an ajax call is called and the available models are retrieved in json format. I can get the ajax call to fire and I’m getting the data back formatted correctly but I can’t get the model drop down to update with the new value (json value pairs). I do not have ID’s because some of the rows are dynamically added so I need to reply on traversing the DOM with items such as .next(), .find(), etc, and I’m not very good with this yet.

Here is the form:

<div class="field inline">
<label class="frmFlds_labels">Platform</label>
<select name="platform" onChange="updateModels(this,18);" class="platform">
    <option value=""></option>
    <option value="IBM" selected="selected">AIX</option>
    <option value="HP">HP-UX</option>
    <option value="LINUX">Linux</option>
    <option value="SUN">Solaris</option>
    <option value="WINTEL">Wintel</option>
    <option value="Other">Other</option>
</select>
</div>
<div class="field inline" platform="IBM">
<label class="frmFlds_labels">Model</label>
<select name="model" class="model">
    <option value=""></option>
    <option value="LPAR on p550">LPAR on p550</option>
    <option value="LPAR on p561">LPAR on p561</option>
    <option value="LPAR on p570">LPAR on p570</option>
</select>

Here is the JS Code:

function updateModels(i,id){
var pltfrm = $(i).val();
var firstOption = $(this);
$.getJSON("index.cfm?do=misc.getModels&platform=" + pltfrm,
    function(j){
        var options = '';
        for (var i = 0; i < j.length; i++){
            options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
        }
        firstOption.next().children('.model').html(options);
    });
}
  • 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-30T17:27:50+00:00Added an answer on May 30, 2026 at 5:27 pm

    IF you change your layout just a bit removing the code from the markup:
    I added a custom attribute: data-id

    <div class="field inline">
       <label class="frmFlds_labels">Platform</label>
       <select name="platform" data-id="18" class="platform">
         <option value=""></option>
         <option value="IBM" selected="selected">AIX</option>
         <option value="HP">HP-UX</option>
         <option value="LINUX">Linux</option>
         <option value="SUN">Solaris</option>
         <option value="WINTEL">Wintel</option>
         <option value="Other">Other</option>
     </select> 
    </div> 
    <div class="field inline" platform="IBM">
     <label class="frmFlds_labels">Model</label>
     <select name="model" class="model">
         <option value=""></option>
         <option value="LPAR on p550">LPAR on p550</option>
         <option value="LPAR on p561">LPAR on p561</option>
         <option value="LPAR on p570">LPAR on p570</option>
     </select> 
    </div>
    

    then use this:

    function updateModels(p, id) {
        var firstOption = $(p);
        var pltfrm = firstOption.val();
        var model = firstOption.parent().next().find('.model');
        $.getJSON("index.cfm?do=misc.getModels&platform=" + pltfrm, function(j) {
            var options = '';
            for (var i = 0; i < j.length; i++) {
                options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
            }
            model.html(options);
        });
    }
    $('.platform').change(function() {
        var id = $(this).attr('data-id');
        updateModels($(this), id);// I do not see you using the id but...
    });
    

    EDIT: Different code if things get added dynamically to the page:

    $(document).on('change','.platform', function() {
        var id = $(this).attr('data-id');
        updateModels($(this), id);// I do not see you using the id but...
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have form that checks if a user has unsubmitted changes when they
I have a parent form which saves the settings and changes user puts. But
I have 60% Opaque form. And when the user changes the color of the
I have a form with multiple fields, and each time the user changes a
When a user have changed something in a form, then clicks on any link
I have form with user defined filters ( combobox with column names, combobox with
I have form where user submits field. Field can have letters, numbers, and punctuation.
I have a form a user can enter their name, then it will add
in my application i have an form where user enter their username first .
I have a form where the user can upload a zip file, it works

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.