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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:29:38+00:00 2026-06-04T04:29:38+00:00

iam newbie here.. please execuse if iam asking wrong question here. iam developing dynamic

  • 0

iam newbie here.. please execuse if iam asking wrong question here.
iam developing dynamic page having two drop down boxes in which second automatically refreshed based on selection of value from first drop down.iam using jquery $.html to automatically refresh second drop down.

$("#subcategory").html('<select name="sub_category" class="valid" id="subcategory"><option>Art - Classes</option><option>Beautician Courses</option><option>Computer - Multimedia Classes</option><option>Cooking - Classes</option><option>Hobby - Classes</option><option>Language Classes</option><option>Motor driving - Classes</option><option>Music - Theatre - Dance Classes</option><option>Professional courses - tutions</option><option>Summer - Camps</option><option>Training Instutions</option><option>Tutoring - Private Lessons</option><option>Other Classes</option></select>').show();

instead of above one i would like to try with json object and populate second drop down.
my json data will be as below:

var data = {
  cat_1: {
    {"id": "1",
    "sub_cat": "sub1"},
   {"id":"2",
   "sub_cat":"sub2"}

  },
  cat_2: {
    {"id": "3",
    "sub_cat": "sub3"},
   {"id":"4",
   "sub_cat":"sub4"}
  }
};

if user selects category 1 second drop down should populate value from cat_1.

iam using below code. but i dont know where to restrict or filter based on selection from first drop down

 $.each(data, function(index, array,array1) {
               // options[options.length] = new Option(array['variety']);
            options[options.length] =new Option(array['id'],array['sub_cat']);
  • 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-04T04:29:39+00:00Added an answer on June 4, 2026 at 4:29 am
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                var data = { 'cat_1': [{ "id": "1", "sub_cat": "sub1" }, { "id": "2", "sub_cat": "sub2"}],
                    'cat_2': [{ "id": "3", "sub_cat": "sub3" }, { "id": "4", "sub_cat": "sub4"}]
                };
                //ggg
    
                $('#ddlCat').on('change', function (e) {
                    $('#ddlSubCat').html('');
                    if (data[$(this).val()] !== undefined) {
                        $.each(data[$(this).val()], function (i, entity) {
                            $('#ddlSubCat').append($('<option />', { 'value': entity.id, 'text': entity.sub_cat }));
                        });
                    }
                });
    
                $('#ddlCat').trigger('change');
            });
        </script>
    </head>
    <body>
        <div id="subcategory">
            <select id="ddlCat">
                <option value="cat_1">cat_1</option>
                <option value="cat_2">cat_2</option>
            </select>
            <select id="ddlSubCat">
            </select>
        </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a newbie iam using jstl and spring,here i am having a jsp
Could someone please tell me what I am doing wrong? I'm not a newbie
Bit of a Rails newbie here so please bear with me. I am trying
Total newbie here, please bear with me. Building a very small personal app that
Ok, total Cucumber newbie here so please be gentle. As a learning Ruby/Cucumber/MongoDB endeavor
Mysql , php newbie here. Please be nice . I have a list of
I am newbie to MSMQ. Here is my scenario: Once the bill is generated
Rails newbie here struggling with a small project. I am creating a simple ship
I am a newbie and just learned that if I define say package my.first.group.here;
I am a regex newbie and can't seem to figure this one out. Here

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.