473,466 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to change the option of one combo box on change other combo box item?

2 New Member
I have two combo box.Like combo1 and combo2.In combo1 i have list of countries.On select of specific country i would like get the respective district options in combo2.

using java script
Thanks & Regards
Jan 21 '11 #1
1 1675
RamananKalirajan
608 Contributor
Hi Binod Bihari,
This is a sample. I dont know how much it will be useful for you.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. var district = new Array("dis1;dis11;dis111;dis1111","dis2;dis22;dis222;dis2222","dis3;dis33;dis333;dis3333");
  5. function loadDist(ths)
  6. {
  7.     //alert(ths.selectedIndex);
  8.     var disSel = document.getElementById('district');
  9.     if(ths.selectedIndex>=1){
  10.       var selDis = district[ths.selectedIndex-1];
  11.       var selDisArr = selDis.split(";");
  12.       while(disSel.length>1)
  13.         disSel.remove(1);
  14.       for(var i=0;i<selDisArr.length;i++)
  15.       {
  16.         if(window.ActiveXObject)
  17.             disSel.add(new Option(selDisArr[i],selDisArr[i]));
  18.         else
  19.             disSel.add(new Option(selDisArr[i],selDisArr[i]),null);
  20.       } 
  21.     }
  22. }
  23. </script>
  24. </head>
  25. <body>
  26. <table>
  27. <tr>
  28.     <td>
  29.         City
  30.     </td>
  31.     <td>
  32.         &nbsp;&nbsp;&nbsp;
  33.     </td>
  34.     <td>
  35.         <select name="city" id="city" onchange="loadDist(this)">
  36.             <option selected>--Select--</option>
  37.             <option value="1">City1</option>
  38.             <option value="2">City2</option>
  39.             <option value="3">City3</option>
  40.         </select>
  41.     </td>
  42. </tr>
  43. <tr>
  44.     <td>
  45.         District
  46.     </td>
  47.     <td>
  48.         &nbsp;&nbsp;&nbsp;
  49.     </td>
  50.     <td>
  51.         <select name="district" id="district">
  52.             <option selected>--Select--</option>
  53.         </select>
  54.     </td>
  55. </tr>
  56. </body>
  57. </html>
Thanks and Regards
Ramanan Kalirajan
Feb 8 '11 #2

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

Similar topics

4
by: mr_burns | last post by:
hi, using javascript, how do i select an option in a combo box? i have tried looking on the internet but dont really know what i should be searching for. what i want to happen is that when a...
5
by: Harry Haller | last post by:
<select name="cboPlaces" id="cboPlaces"> <option value="3">Countryside</option> <option value="4">Forest</option> <option value="5">Mountain</option> <option value="6">Desert</option> <option...
3
by: MLH | last post by:
I wish to give user a tool to select period of car purchase. (IE, the block of time within which sale made) So, I'm gonna give him an option-group of choices like... this week this month last...
2
by: simon | last post by:
I have list box populated with the dataReader. Then I add one item and I want that this item would be the first one in the listBox. Now, It's the last. Can I change the position of the item in the...
2
by: B | last post by:
I'm trying to simply build a form with a combo box containing a list of states. I'd like for there to be NO default selected item, but invariably, the first item in the DataSource is being...
1
by: Doug White | last post by:
How do I make a value the default value for a combo box in ASP 3.0? What I have below does NOT work, yet I've seen it in HTML file examples before (and works if I put it in a HTML file by itself, but...
3
MattFitzgerald
by: MattFitzgerald | last post by:
I have a combo box on the form which is used as the criteria for a field in the query . I want to be able to run the query for a specific or all agents. I have added to the row source of the...
3
by: CSharper | last post by:
Is it possible to selectivly change the color of an item in text. I saw ForeColor option, but it changes the color of all the items. If it is not possible, is there any other control list listbox...
40
by: HSXWillH | last post by:
I have a large query with 6 selection fields that I allow the user to choose any and all from 1 single input form. The 6 option fields on Form SearchForm are: Track, Distance, Surface,...
1
by: shalskedar | last post by:
In my DB i need to change the value for a Combo Box based on some condition.. These values r retrieved from 1 of the tables(Glass) My Query is in my form 1 of the Combo boxes display these...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.