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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:37:46+00:00 2026-05-21T12:37:46+00:00

I have this dropdown (select) menu generated with JQuery, dynamically using JSON coming from

  • 0

I have this dropdown (select) menu generated with JQuery, dynamically using JSON coming from PHP script.
Refer on the picture attached, under the Components label. The “select” menu holds Component name and Component ID (value).
example

I want “on change” event, using JQuery, to populate the following fields Code, Category and UOM, with corresponding values.

My JSON object retrieves everything what is needed (I managed to achieve this with JQuery autocomplete).

eg.

[{"id":"4","component":"Component 1","code":"COMP1","uom":"kilo","category":"Flour"}...]

This is my code for generating the “select” menu with options inside coming from the above mentioned JSON.

$.getJSON("<?php echo site_url('products/dropdown/no'); ?>", function(result) {
            var optionsValues = '<select>';
            optionsValues += '<option value="">' + '--' + '</option>';
            $.each(result, function() {
            optionsValues += '<option value="' + this.id + '">' + this.component + '</option>';
            });
            optionsValues += '</select>';
            var options = $("select[name=component]");
            options.replaceWith(optionsValues);  
        });

It is located in the $(document).ready.

So, I need function or something which whenever change in the “select” menu occurs, it will populate the mentioned fields around with corresponding values.

Thank you very much in advance.

  • 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-21T12:37:46+00:00Added an answer on May 21, 2026 at 12:37 pm
    $('select').change(function(){
       //Populate other fields
       //$.getJSON()
       //$('input.code').val(response.code)
       //etc...
    });
    

    Or if you generate the select element after the page has loaded, you can use:

    $('select').live('change', function(){
       //Populate other fields
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple html option/select (dropdown) menu. I want to use JQuery to
I have a little dropdown menu similar <select> , which contolled from external js-function.
I have a model of objects in a dropdown menu: <select id=group_select name=group_select> <option
I have this code in jQuery, that I want to reimplement with the prototype
I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
Using NetBeans, I have generated Hibernate mapping files and set of POJOs. I have
I have a dropdown menu. When I click on Italian in the dropdown, I
On this site: http://www.rent-turkey-property.com/ I have it set so that when you select a
I'm using the JQuery DatePicker to have the user pick a date and have

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.