I like to design a webpage using jsp.it has two comnbo boxes ,the information in the second box should vary accordingly to which i select inthe first. for example take the first as states , when i select one from it the corresponding cities of that bstate should load in the second combo box.please tell me how to do it

Questions by jacintha

Showing Answers 1 - 1 of 1 Answers

Jayesh

  • Oct 2nd, 2006
 

Hello,

For that u don't need to use the jsp script. U can manage it by Javascript.

Make the associate array of state and city in havascript.

<script>

city_arr =  new Array();

city_arr['State_code1']=new Array();

city_arr['State_code1']=[['City name 1'],['City name2'], ['City name2']];

city_arr['State_code2']=new Array();

city_arr['State_code2']=[['City name 11'],['City name22'], ['City name23']];

function displayCityByState(stateCode){

      if(city_arr[stateCode]){

             for(i=0, n=city_arr[stateCode].length; i<n ; i++){

                     alert(city_arr[stateCode][i]);

             } 

     }

}

//eg. To call function when u change the value of dropdown (State)

displayCityByState('State_code1');

</script>

So u've to store javascript variable and their values through your jsp script in browser.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions