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
- function loadProject()
- {
- xmlhttp=GetXmlHttpObject();
- if (xmlhttp==null)
- {
- alert ("Your browser does not support Ajax HTTP");
- return;
- }
- var project = document.getElementById("Project").value;
- //alert(project);
- var url="Project.jsp";
- url=url+"?Project="+project;
- //alert(url);
- xmlhttp.onreadystatechange=Output;
- xmlhttp.open("GET",url,true);
- xmlhttp.send(null);
- }
- function Output()
- {
- if (xmlhttp.readyState==4)
- {
- var result = xmlhttp.responseText;
- var s = result.split(" ");
- var indx =1;
- for(indx=1; indx < s.length;indx++)
- {
- document.frm.Stage.options[indx] = new Option(s[indx]);
- }
- }
- }
- function GetXmlHttpObject()
- {
- if (window.XMLHttpRequest)
- {
- return new XMLHttpRequest();
- }
- if (window.ActiveXObject)
- {
- return new ActiveXObject("Microsoft.XMLHTTP");
- }
- return null;
- }
Expand|Select|Wrap|Line Numbers
- <select name="Project" id="Project" onChange="return loadProject();">
- <option value="-1">---Please select---</option>
- <%while(rs1.next())
- {
- %>
- <option value="<%=rs1.getString(1)%>"><%=rs1.getString(1)%> </option>
- <%}%>
- <%
- rs1.close();
- %>
i need to clear cache at the time in my form while Onchange event happening...
please help MEEE....