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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:47:59+00:00 2026-05-29T19:47:59+00:00

I tried, googled a lot but still finding for a solution. My problem is

  • 0

I tried, googled a lot but still finding for a solution. My problem is simple just i want to populate child combo box in index.jsp after an onchange event in parent combo box. I have used JSON array objects to retrieve but not populating child combo, any help please?
When i select ABC then automatically 001 will be populated in second combo box, similarly when i select PQR then 002 will be populated and 001 will be removed.

index.jsp

 <script type="text/javascript">
 $(document).ready(function() {
 $("#combobox1").change(function() {// by onchange event in parent combo box i want to populate 
 child combobox 
$.getJSON('state.jsp', {count : this.value}, function(responseData) {
$("#combobox2").append(
$("<option></option>").html(responseData.name).val(responseData.name)
);
});
});
});          
</script>

 <body>  
//parent combo box
<select id="combobox1" name="count">
<option value="abc">ABC</option>
<option value="pqr">PQR</option>
</select>
 // child combo box

<select id="combobox2" name="combobox2">// here i want to populate data `001` by `ABC` or `002` by selecting `PQR` , how can i do it?
<option value="">select</option>
</body> 

state.jsp

 <%@page import="net.sf.json.JSONObject"%>
 <%@page import="net.sf.json.JSONArray"%>
 <%
 String count=request.getParameter("count");
 if(count.equals("ABC"){
 JSONObject arrayObj= new JSONObject();
   arrayObj.put("name","001");// how to populate `001` in an option in child combo box when `ABC` will be selected in parent combo?
  response.setContentType("application/json");
  response.getWriter().write(arrayObj.toString());
}
else if (count.equals("PQR"){
 JSONObject arrayObj= new JSONObject();
arrayObj.put("name","002");// how to populate `002` in an option in child combo box when `PQR` will be selected in parent combo?
  response.setContentType("application/json");
  response.getWriter().write(arrayObj.toString());
}
%>
  • 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-29T19:48:06+00:00Added an answer on May 29, 2026 at 7:48 pm

    Using my example code provided in Clean old options from child dropdown when receiving data by JSON

    You need to case insensitive comparison of the count field (as the original poster in the other thread does), as you pass back one of the following values:

    • abc
    • pqr

    and you are checking for:

    • ABC
    • PQR

    What you are looking for never exists, so you will never return any data for the second combo.

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

Sidebar

Related Questions

I searched lot in google and tried my level best but, still i cant
I have been trying to solve this problem all day, I googled a lot,
I searched in this group and googled around, but still no luck in answers
This may have been asked a lot but I'm still lost. I need to
Pretty self-explanatory, I tried google and got a lot of the dreaded expertsexchange, I
The question is pretty much self-explanatory. I Googled many sites, many methods, tried many
Ok... I tried google and didn't get many hits. I dont want to abuse
I tried to find the difference on Google. BUT I 'm not able to
I tried my hand at this Google Codejam Africa problem (the contest is already
I think I might be about to ask a dummy question, but I'm still

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.