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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:15:02+00:00 2026-06-13T07:15:02+00:00

I am having two combo box in my UI. The first combo box contains

  • 0

I am having two combo box in my UI. The first combo box contains the list of country names and the second combo box contains list of states present in that country. From the first combo, when I select the country, then the name is sent to the servlet. Using the name, the DB is hit, list of state names are retrieved and converted into JSONObject. Now I am not able to pass this JSONObject back to the extjs file for populating the second combobox with list of states.

Here is the code for the js file:

    Ext.require('Ext.tab.*');
Ext.require('Ext.button.*');

Ext.define('Country',{
    extend: 'Ext.data.Model',
    fields: [
        { name: 'id', type: 'string' },
        { name: 'name', type: 'string' }
    ]
});

Ext.define('CountryCombo', {
    extend: 'Ext.form.field.ComboBox',
    alias: 'widget.countrycombo',
    allowBlank: false,
    queryMode: 'local',
    valueField: 'id',
    displayField: 'name',
    store: {
        model: 'Country',
        data: [
            { id: 'China', name: 'China'},
            { id: 'Japan', name: 'Japan'},
            { id: 'Malaysia', name: 'Malaysia'}
        ]
    },
    listeners: {
        "select": function(obj){  
            Ext.Ajax.request({
                url: '/CellEditing/FormServlet',
                method: 'POST',
                params: {
                    data: obj.getValue()
                },
                success: function(obj){
                    alert('sucess');
                    var respText = eval('('+ obj.responseText +')');
                    alert(respText);
                },
                failure: function(obj){
                    alert('failure');
                }
            });                 
        }
    }
});

Ext.define('State',{
    extend: 'Ext.data.Model',
    fields: [
        { name: 'id', type: 'int' },
        { name: 'name', type: 'string' }
    ]
});

Ext.define('StateCombo', {
    extend: 'Ext.form.field.ComboBox',
    alias: 'widget.statecombo',
    allowBlank: false,
    queryMode: 'local',
    valueField: 'id',
    displayField: 'name',
    store: {
        model: 'State',
        data:[]
    }
});

Ext.onReady(function(){
    Ext.tip.QuickTipManager.init();
    Ext.widget('panel', {
        renderTo: 'pan1',
        title: 'Basic Panel',
        width:600,
        height:100,
        defaults: {
            bodyPadding: 10,
            border: false,
            xtype: 'panel',
            layout: 'anchor'
        },
        layout: 'hbox',
        items: [{
                  fieldLabel: 'Country',
                  xtype: 'countrycombo',
                  width: 234,
                  margin: '5 5 5 5'
               },{
                  fieldLabel: 'State',
                  xtype: 'statecombo',
                  width: 234,
                  margin: '5 5 5 5'
               }]            
    });  
});

Here is the servlet:

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    // TODO Auto-generated method stub
    System.out.println("Inside Post");
    String selectedValue = req.getParameter("data");
    System.out.println(selectedValue);
    //This is the json string I want to send back to the UI
    //The format of this json is correct, I verifieded it printing in console.
    String jsonString = new StateHelper().getStates(selectedValue);
    //Below are the lines I am having the doubt, it is not correct.
    req.setAttribute("data", jsonString);
    req.getRequestDispatcher("combo.jsp").forward(req, resp);
}

combo.jsp is the file containing both the combo box. Running this code, I am getting the alert with “failure” message.

Its telling: syntax error in this line:

var respText = eval('('+ obj1.responseText +')');

Please let me know how to resolve this problem.

  • 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-13T07:15:03+00:00Added an answer on June 13, 2026 at 7:15 am

    var respText = Ext.JSON.decode( obj.responseText );

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

Sidebar

Related Questions

I'm having two sortable lists where I can add items from the first list
Having two different .tar.gz files: The second .tar.gz is the subset of first .tar.gz.
Imagine having two list boxes on a form, where the choices in the second
I'm having two tables, I need to select some data joined from both of
Goal: Having two buttons that should be enable to add or delete data from
I'm having two behavioral issues that I can't overcome. First, I can't successfully scroll
We are having two load balancing server. In that we have hosted a asp.net
I'm having two jquery's that I run and I want to combine them both
I am having trouble setting the row source of a certain combo box on
Hi I have a combo box having 5 drop down items in Tab1 and

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.