I need some help. I set up an array with values in them and want to use them later in a javascript routine that will be invoked from a selection on a form.
The array entry I want to use is called "suburbcount()" and the actual array number will equal that of "cityindex" in the javascript routine which is the "selectedIndex" value.
However, I am not sure how I will set it up to pass through to the javascript routine or alternatively how I would define it as maybe a hidden element in the form. What I pass through now I know is incorrect as the "indexctr" has been reset to 0, however, it relates to the "selectedIndex" value at this point.
Many thanks for any help.
My code is as follows :
*** My code for setting up the array ****
*** Code for my form with some print statements to check array set up okay - which it is ***Code:indexctr = 2 do until indexctr = citycount sqlstring = "select * from [location-area] where [city-town] = " & chr(34) & displaycity(indexctr) & chr(34) & " order by [area];" call adorecordset.open(sqlstring,adoconnection,adopenstatic,adlockreadonly) suburbcount(indexctr) = adorecordset.recordcount adorecordset.close indexctr = indexctr + 1 loop
*** javascript routine *****Code:<form name="selectcity" method="post"> <!--Full Area SELECTION - (but only City / Town) --> <% indexctr = 0 do until indexctr = citycount %> <a><%=indexctr%> - <%=displaycity(indexctr)%> - <%=suburbcount(indexctr)%></a><br /> <% indexctr = indexctr + 1 loop indexctr = 0 %> <a class="blueinformation">Detailed list of <%=statename%> Cities and Towns</a><br /><br /> <select class="information" name="city" onchange="cityselection('<%=databaseid%>','<%=programid%>','<%=suburbcount(indexctr)%>')"><%=cityoption%></select> <!--HIDDEN FORM VARS--> <input type="hidden" name="countryindex" value="<%=areadictionary.item("countryindex")%>"></input> <input type="hidden" name="databaseid" value="<%=databaseid%>"></input> <input type="hidden" name="suburb" value="<%=allsuburbs%>"></input> <input type="hidden" name="selectedindex" value=""></input> </form>
Code:function cityselection(databaseid,programid,suburbcount) { var cityindex = document.selectcity.elements["city"].selectedIndex; var selectedcity = document.selectcity.elements["city"].value; if (cityindex == 0) { alert("Please Enter a Valid Option"); return; } if (suburbcount == 0) { document.selectcity.action = "testcity.asp?databaseid=" + databaseid + "&programid=" + programid + "&suburbindex=None" + "&cityindex=" + cityindex + "&suburbcount=" + suburbcount; document.selectcity.submit(); } else { document.selectcity.elements["selectedindex"].value = cityselection-2; document.selectcity.action = "suburblist.asp?databaseid=" + databaseid + "&programid=" + programid; document.selectcity.submit(); } }


Reply With Quote
Do you understad?
Bookmarks