473,461 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to change the values of a drop box based on another drop box

2
Hi, i am using a jsp page that has 2 drop down boxes ,one is country and other is territory.I want to change the value of territory and on the change of country and one more requirement is that country drop down gets loaded with the arraylist in which result of query will be saved....I need urgent help.Thanks in advance!
Sep 23 '10 #1
3 1888
Oralloy
988 Expert 512MB
Sounds like you're going to have to code some javascript into your page. What exactly are you trying to achieve?

1) Change country, the available territory list immediately, and silently changes?

2) Change country, the server is queried for a new territory list, which is then silently used to update the current page?

3) Change country, the page reloads with an updated territory list?

These are all variations on the theme. What matters are your requirements.
Sep 23 '10 #2
akshma
2
yes i think i would have to write javascript code.I want is the first 2 cases that you have written above,,,,i.e territory list changes with change in country and a query will be called in which country name will be passed.
Sep 23 '10 #3
Oralloy
988 Expert 512MB
Ok, it'll look something like this, but the javascript is probably wrong in the details. There are other folks here who might be able to help you with better craftsmanship.

Expand|Select|Wrap|Line Numbers
  1. <select name="country" id="country">
  2.  <option value="">Please select...</option>
  3.  <option value="-1">None</option>
  4.  <option value="100">Country 0</option>
  5.  <option value="101">Country 1</option>
  6.  <option value="102">Country 2</option>
  7. </select>
  8.  
  9. <select name="territory" id="territory">
  10.  <option class="" value="">Please select...</option>
  11.  <option class="-1" value="-1">None</option>
  12.  <option class="100" value="">Please select...</option>
  13.  <option class="100" value="-1">None</option>
  14.  <option class="101" value="">Please select...</option>
  15.  <option class="101" value="-1">None</option>
  16.  <option class="101" value="1011">Country 1, Territory 1</option>
  17.  <option class="101" value="1012">Country 1, Territory 2</option>
  18.  <option class="101" value="1013">Country 1, Territory 3</option>
  19.  <option class="101" value="1014">Country 1, Territory 4</option>
  20.  <option class="102" value="">Please select...</option>
  21.  <option class="102" value="1021">Country 2, Territory 1</option>
  22.  <option class="102" value="1022">Country 2, Territory 2</option>
  23.  <option class="102" value="1023">Country 2, Territory 3</option>
  24. </select>
  25.  
  26. <script> 
  27.  document.getElementById('country').onchange =
  28.   function(event){
  29.    territory = document.getElementById('territory');
  30.    newCountry  = this.value
  31.  
  32.    for (ix=0; ix<options.length; ix++)
  33.     if (options[ix].class = newCountry)
  34.       options[ix].style.display = ''
  35.     else
  36.       options[ix].style.display = 'none'
  37.   };
  38. </script>
  39.  
Sep 23 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Leigh | last post by:
I am building a data entry application using Java servlets. I had hoped to use drop down boxes to provide the user with data entry selections pulled from a database, but am now questioning, given...
5
by: MasterChief | last post by:
I have 3 drop down boxes on the same page. Each one is being populated by a database. One is called Location, One is called Device and the other one is called Job Title. When the user selects...
7
by: callawayglfr | last post by:
I am building a database in access where I have a drop down box that relates to a text box, that part I have working but when someone selects information from the first drop down I need it to limit...
2
by: ckerns | last post by:
I have a page with a bunch of drop down boxes. They are named: MonEquipAMWk1 MonEquipPMWk1 thru FriEquipAMWk1 FriEquipPMWk1
5
by: dynamitez | last post by:
Hi there, I need some help! I want to create 2 dependent dynamic drop down boxes which choices of box 2 depends on the choice chosen from box 1. Ex. Box1 -western -eastern Box2 (If...
3
by: amcoldspy | last post by:
Hi, am trying to create dynamic drop down boxes.. there are 3 drop down boxes. The second drop down box elements are to be update based on the selection made in the first drop down box...
10
by: kashhere | last post by:
hi all, i had two drop down boxes on the selection of one item in the first drop down box the related items should be changed in the second one can any one please suggest me towards the solution...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.