473,785 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ 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 1705
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
8844
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 function is called a line of code will select a specific option in a combo box. something like: //excuse the dodgy syntax
5
17217
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 value="7">Jungle</option> <option value="7">Swamp</option> <option value="8">River</option> <option value="12">Town</option> <option value="9">Sea</option>
3
1480
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 month in last 3 months in last 6 months And, in case none of the above 5 are good enough to sufficiently
2
2800
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 listBox from the last to the first? lstMedia.DataSource() = funkcije.createDataReader(sql, True) lstMedia.DataValueField = "med_id" lstMedia.DataTextField = "med_name" lstMedia.DataBind()
2
2493
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 displayed. It seems to work fine on other forms, but for one particular form, nothing I do seems to work. My code is basically: string SQL = ""; SQL = "SELECT StateAbbreviation FROM States ORDER BY StateAbbreviation";
1
1664
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 not if I use it in a ASP 3.0 app) I have also seen messages in this forum that says it should work, but I've tried it two different asp 3.0 apps and it is not working and I don't know why. <select name="cboCompany" style="text-align:right;...
3
1557
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 combo box the following code:- SELECT DISTINCT Qry_Cadbury_Data_Linked_to_BT_Data_By_Vol. FROM Qry_Cadbury_Data_Linked_to_BT_Data_By_Vol; UNION SELECT '*' AS FROM Qry_Cadbury_Data_Linked_to_BT_Data_By_Vol; and added the following code to the...
3
29320
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 where we can see more than one item and change the color during run time. Thanks.
40
2241
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, Track_Condition, Final_Pos and Race_Type. The 6 particular combo boxes are cboTrack, cboDistance, cboSurface, cboTrkCond, cboFinalPos and cboRaceType. I've set up a query/filter that works using the selection criteria !!etc... in alternating manners so...
1
2306
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 values,but i need to change these values once the form is Loaded. For Ex-If the Combo Box contains value as "Sliding door" it shud display the value in the Form as "SD". Here for this if the table contains 10 such records as "Sliding Door",then for all ...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
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 we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.