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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:01:04+00:00 2026-06-08T02:01:04+00:00

i am write some code for cascading drop down with dojo ajax first drop

  • 0

i am write some code for cascading drop down with dojo ajax first drop down is static and second one is fetch the data from servlet .. i am using the dijit.form.ComboBox for make dropdown. Dojo provide the Store property in which he store the data and then put it into combobox. in servlet i through the array list to ajax function .. in ajax function i separate the array with comma and strore in variable and then store in the dojo’s store property But i am not able to populate the whole string .. it populate only the last value of the string i am using following code

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

        <link rel="stylesheet" href="dojo/dijit/themes/claro/document.css">
        <link rel="stylesheet" href="dojo/dijit/themes/claro/claro.css" />
        <script src='dojo/dojo/dojo.js' data-dojo-config=' parseOnLoad: true'></script>
        <script>



            require(["dojo/parser", "dijit/form/ComboBox","dijit/form/TextBox"]);

      function abc(){    

          var j = document.getElementById('state').value
          dojo.xhrPost({
    // The URL to request
    url: "populate",   //servlet name
    timeout :  3000 ,
    content: {
        username: dojo.byId("state").value

    },

    load: function(result) {    // the value in result is like=[Abas Store, Accounts ]

    require([
    "dojo/ready", "dojo/store/Memory", "dijit/form/ComboBox"
], function(ready, Memory, ComboBox){

     var ss=result.split(",");

     var i;
     for (i=1;i< ss.length ;i++){


    var stateStore = new Memory({

        data: [ {name:ss[i], id: ss[i]}  ]
    });
     }

    ready(function(){
        var comboBox = new ComboBox({
            id: "stateSelect",
           name:"select",
            value: "Select",
            store: stateStore,
            searchAttr: "name"
        }, "stateSelect");
    });
});

      }
});
      }

        </script>
    </head>
    <body class="claro">

     <select data-dojo-type="dijit.form.ComboBox" id="state" name="state"  onchange="abc();">
    <option selected >Andaman Nicobar</option>
    <option>Andhra Pradesh</option>        
 <option>Tripura</option>
 <option>Uttar Pradesh</option>
 <option>Uttaranchal</option>
 <option>West Bengal</option>

</select>
        <input id="stateSelect"  >
                   </select>


    </body>
</html>

please give me solution .. to populate all the value in combobox which is i get from array list

  • 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-08T02:01:05+00:00Added an answer on June 8, 2026 at 2:01 am

    You are building the store in the for loop. Instead, you should build the data array that gets passed into the MemoryStore constructor.

    require(["dojo/store/Memory", "dijit/form/ComboBox", "dojo/ready"], 
        function(Memory, ComboBox, ready){
    
            ready(function) {
    
               dojo.connect(dijit.byId('state'), 'onChange', function() {
    
                   var stateSelect = dijit.byId('stateSelect');
                   if (!stateSelect) {
                       stateSelect = new ComboBox({
                         id: "stateSelect",
                         name:  "select",
                         value: "Select...",
                         searchAttr: "name"
                       }, "stateSelect");
                   }
    
                   var ss = 'Abas Store, Accounts';
                   ss = ss.split(',');
    
                   var data = [];
                   dojo.forEach(ss, function(item, idx) {
                       data.push({
                           id: idx,
                           name: item                    
                   });
                   stateSelect.set('store', new Memory({data: data}));
    
              }); // dojo.connect
           }); // ready     
    }); // require
    

    ​

    The working example is at http://jsfiddle.net/cswing/DLNNc/

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

Sidebar

Related Questions

I'm trying to write some code to convert data from a object type field
I am trying to write some code that will generate accurate .proto files from
I need to write some code to insert around 3 million rows of data.
I'm trying to write some code to Hide columns if the first 3 characters
I'm trying to write some code to remove the first N characters in a
I'd like to write some code that would take a given data frame, check
I'm trying to write some code using OpenCV. My sensor is from Point Grey
I am trying to write some code which retrieves the first 10 words of
i have to write some code that initialize my data app. This must be
I am trying to write some code that uses SQL to delete rows from

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.