Hi Guddu,
sure...here it is...
Code:
var Region = new Array();
var District = new Array();
function addRegion(region) {
v = Region.length;
Region.length ++;
Region[v] = region;
v = District.length;
District.length ++;
District[region] = new Array();
}
function addDistrict(region,district) {
v = District[region].length;
District[region].length ++;
District[region][v] = district;
}
function loadRegionList() {
var ctrlRegion = document.frmSend.Region;
ctrlRegion.options.length = 0;
for (i=0;i<Region.length;i++) {
ctrlRegion.options[i] = new Option(Region[i],Region[i]);
}
}
function loadDistrictList() {
var ctrlRegion = document.frmSend.Region;
var selRegion = ctrlRegion.options[ctrlRegion.selectedIndex].value;
var ctrlDistrict = document.frmSend.District;
ctrlDistrict.options.length = 0;
for (i=0;i<District[selRegion].length;i++) {
ctrlDistrict.options[i] = new Option(District[selRegion][i]);
}
}
on the body tag:
Code:
<BODY onload="loadRegionList();loadDistrictList();">
then, concatenate is my district name:
Code:
<%
strSQL = "Select RegionNm, Concatenate from vwReg_Dist Order by RegionNm,Concatenate"
set rs = conn.execute(strSQL)
if rs.eof then
response.write("No Region Found")
rs.close
set rs=nothing
response.end
end if
strRegion = ""
strDistrict = ""
do until rs.eof
if not rs("RegionNm") = strRegion then
response.write("<script>addRegion('" & rs("RegionNm") & "')</script>")
response.write("<script>addDistrict('" & rs("RegionNm") & "','" & rs("Concatenate") & "')</script>")
strRegion = rs("RegionNm")
strDistrict = rs("Concatenate")
else
if not rs("Concatenate") = strDistrict then
response.write("<script>addDistrict('" & rs("RegionNm") & "','" & rs("Concatenate") & "')</script>")
strDistrict = rs("Concatenate")
end if
end if
rs.MoveNext
loop
rs.close
set rs=nothing
set conn=nothing
%>
my table info:
Code:
<tr>
<td CLASS="fieldLblB" WIDTH="120">Region:</td>
<td>
<select size="1" name="Region" onChange="loadDistrictList();">
</select>
</td>
</tr>
<tr>
<td CLASS="fieldLblB" WIDTH="120">District</td>
<td>
<select size="1" name="District">
</select>
</td>
</tr>
unclear how the javascript equals asp, normally my <select> tag would have an <option> following calling rs value.
also, since i don't have a blank record, how do i get something like <option value="">Select Region</option> as the default instead of it defaulting to the first Region Name,DistrictName? Is this possible?
Thanks!
Bookmarks