473,796 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ajax code for combo box(list box)

18 New Member
hi dere,

i'm new to ajax.. i did a small example using it successfully.. but the problem i'm facing is, how to display the data in a combo box.. if i know the no.of values that is coming from db i can do it, however i don know the no.of records in db..

to be more simple, if i select a country, corr.states of that country should come..
below is the code i used to dispaly if i kno the no.of records in the db

Expand|Select|Wrap|Line Numbers
  1. function ajaxFunction()
  2. {
  3. var xmlHttp;
  4. try
  5.   {  // Firefox, Opera 8.0+, Safari 
  6.   xmlHttp=new XMLHttpRequest();
  7.   }
  8. catch (e)
  9.   {  // Internet Explorer  
  10.   try
  11.     {    
  12.     xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
  13.     }
  14.   catch (e)
  15.     {   
  16.     try
  17.       {     
  18.       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");   
  19.       }
  20.     catch (e)
  21.       {    
  22.       alert("Your browser does not support AJAX!");   
  23.       return false;    
  24.       } 
  25.       } 
  26.       }
  27.   xmlHttp.onreadystatechange=function()
  28.     {
  29.     if(xmlHttp.readyState==4)
  30.       {
  31.       var array;
  32.       array=xmlHttp.responseText.split("|")
  33.       document.form2.contact.value=array[0];
  34.       document.form2.address.value=array[1];
  35.       document.form2.city.value=array[2];
  36.       document.form2.country.value=array[3];
  37.       }
  38.     }
  39.     var user= document.form2.user.value
  40.     var url = "aswajax?user=" + user;
  41.   xmlHttp.open("GET",url,true);
  42.   xmlHttp.send();  }

any help..
thanks in advance..
regards,
aswathn.s
(knowledge is power
Mar 25 '08 #1
1 1682
acoder
16,027 Recognized Expert Moderator MVP
Either use XML or JSON, or after splitting, use a for loop to loop over the data. That way you don't need to know the number of records.
Mar 25 '08 #2

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

Similar topics

1
2817
by: bbcdancer | last post by:
Is it possible to restrict the length of a text box in MS Access using VBA on condition to what is selected in a list combo box. Scenario: 1. I have a list combo box containing: AA BBB CCCC
2
2385
by: JweldonH | last post by:
My issue probably has a simple answer. I want to limit a populated combo box to items that are NOT in use in another table. I have a Table with a field that looks up values from another table via a combo box. As I select items from that combo box list, I would like for the list to automatically remove that selection from the combo box list so it wont be availble to select. (And have it add any item that I change or remove from the tabe) The...
3
43384
dmjpro
by: dmjpro | last post by:
at first let me clearify .... these (Combo BOX + List BOX) r two different components in html page????? i know how to develope combo box... but list boxxxxxx?????? plz help me .......thanxxx in advance
4
7493
by: access baby | last post by:
i would like to use combobox or list box in a form for data entry do i have to have a table with value in it and the combobox or list box should look in to that table or i type in the values. 'cause when i create a form with text box and change it to combobox the box is empty there are no records in it .
5
3917
FOE2272
by: FOE2272 | last post by:
I have tried every option that I can think of and most of them on this forum. The closest that I got was to bring up the field but it changed the other records based on what was chosen in one record. Details: DB with one main table and several list (reference) tables. I want to populate several list boxes on one form based on a choice from a combo box. Example: Tables:
2
1881
by: Jacko7289 | last post by:
Good Day, My form has two combo boxes where the list of second combo box is dependent on the data chosen from the first combo box. This is how the table (source of data) looks like... Table 1: PROD Prod (PK) Prod_Desc Table 2: PROD_CAT Prod (FK)
6
18426
by: troy_lee | last post by:
I have a continuous form that has one combo box (cbo1) with the selectable values of "Removal" and "Installation". I would like to change another combo box (cbo2) value list based on the selection in cbo1. For example, when the user selects "Removal" from cbo1 I would like the value list of cbo2 to be one set of values and when "Installation" is selected in cbo1 I would like the value list of cbo2 to be a different set of values.
0
324
by: Simon | last post by:
Dear reader, In a combo-box there a possibility that by typing the right combination the string in the combo-box will grow to the correct combination in your pick list. So far I know is the property setting to achieve this Auto Expand yes. But the behaviour of my combo-box is not what I expect, I can only select the text from a pick list and not by typing.
5
4180
by: Kaosman | last post by:
I have been trying to figure out this problem for a while. All I want to do is have a combo box populate a list box and the list box change to the record based on the users choice. The combo box is active and find a record based on user input. The list box gets its values from the combo box and the list box can also change the form to the record chosen by the user. The list box and combo box are on the same form.
0
10449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10168
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
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...
1
7546
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
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
5440
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
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.