473,508 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to clear a data in dynamic combo box?

28 New Member
Hi,

In my Form(JSP) using ajax i done dynamic combo box.3 combo box is in my Form.

In database country,State,Area is available

Country-->India,Russia,Australia
State---> TN,Del,LL for India.HH,SO for Russia.JO,KO for Australia

Area --->Aa,Bb for TN....

Now if i select Russia in 1st combo box the appropriate state is loading.

But India having three state and other two country's having two state only.

But now my problem is if the user forgottenly select India and in 2nd combo box appropriate state are coming, with the same page the user select Russia mean's 2nd combo box dynamically generating but Russia has two state only right but it showing three state. the first time selected by the user India's third state is not disappearing. i want to delete that Please Help me



below code will load at on OnChange
Expand|Select|Wrap|Line Numbers
  1. function loadProject()
  2. {
  3.  
  4.  xmlhttp=GetXmlHttpObject();
  5.  
  6.   if (xmlhttp==null)
  7.   {
  8.    alert ("Your browser does not support Ajax HTTP");
  9.    return;
  10.   }
  11.  
  12.     var project = document.getElementById("Project").value;
  13.     //alert(project);
  14.     var url="Project.jsp";
  15.     url=url+"?Project="+project;
  16.     //alert(url);
  17.     xmlhttp.onreadystatechange=Output;
  18.     xmlhttp.open("GET",url,true);
  19.  
  20.     xmlhttp.send(null);
  21. }
  22.  
  23.  
  24. function Output()
  25. {
  26.   if (xmlhttp.readyState==4)
  27.   {
  28. var result = xmlhttp.responseText;
  29.     var s = result.split(" ");
  30.             var indx =1;
  31.                         for(indx=1; indx < s.length;indx++)
  32.     {
  33.     document.frm.Stage.options[indx] = new Option(s[indx]);
  34.  
  35.             }
  36.  
  37.       }
  38.  
  39. }
  40. function GetXmlHttpObject()
  41. {
  42.     if (window.XMLHttpRequest)
  43.     {
  44.        return new XMLHttpRequest();
  45.     }
  46.     if (window.ActiveXObject)
  47.     {
  48.       return new ActiveXObject("Microsoft.XMLHTTP");
  49.     }
  50.  return null;
  51. }
  52.  
  53.  

Expand|Select|Wrap|Line Numbers
  1. <select name="Project" id="Project" onChange="return loadProject();">
  2.  
  3. <option value="-1">---Please select---</option>
  4.  
  5. <%while(rs1.next())
  6. {
  7. %>
  8. <option value="<%=rs1.getString(1)%>"><%=rs1.getString(1)%> </option>
  9. <%}%>
  10. <%
  11.     rs1.close();
  12. %>
  13.  

i need to clear cache at the time in my form while Onchange event happening...
please help MEEE....
Apr 7 '11 #1
1 2326
acoder
16,027 Recognized Expert Moderator MVP
You could do 2 things:
1. remove all current options before selecting next option. This can usually be achieved with a single line: sel.options.length = 0;
2. remove all remaining options.
Apr 14 '11 #2

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

Similar topics

13
2869
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when...
3
4287
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
9
3384
by: Bob Alston | last post by:
In 2002, "GrayJay" posted the following code: I did this in a jazz record catalogue to find composers - On a form "frmComposers" Create a text box - txtFindComposer, and add the following sub...
9
4438
by: Kay | last post by:
Hi all, Could you tell me the best way to add a blank item(as first item) in a data binded combo box? Because I think I didn't do it right and it generate an error if the second item(after the...
4
2664
by: Evan | last post by:
I have a data bound combo box. The combo box displays several items (status code descriptions). After the combo box is bound, I want to set the combo box so that the "Draft" status is displayed by...
3
3202
by: anirban | last post by:
I am a novice of VB I want to fetch data from combo box or list which is selected give me a easy way to select the data of combo box or list box I can show data in combo box or list box
3
1424
by: kbannon | last post by:
I have come across a problem whereby occasionally a problem occurs with a data bound combo. The combo has an event which when changed causes a second combo to populate (its also data bound)....
5
1953
by: creative1 | last post by:
Hi, I am designing a data entry JSP form to add payment information. I want to add a combo box on the form that would have list of the compies present in databse. The combo should be populated based...
1
2236
by: pavanip | last post by:
Hi, I have a data grid control and I placed one combo box in that data grid and I am binding data to data grid combo box.When i run the application by default the combo box is not showing anything...
3
5516
by: kumardharanik | last post by:
Pls could anyone help me how to get data from combo box with my following code i used txt_app_code for combo box name. using System; using System.Collections.Generic; using...
0
7224
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
7323
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,...
0
7379
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...
0
7493
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...
0
5625
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
4706
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
3192
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
1550
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 ...
0
415
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...

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.