I am trying to assign the value of the selected field from my form into a variable called selectedcity. It doesn’t work, what is wrong with my syntax or whatever. I have added the parts of my code that I think are relevant.
Many thanks
Jim
*********** javascript code here
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 + “&selectedcity=” + selectedcity + “&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();
}
}
*****************form code here
<form name=”selectcity” method=”post”>
<a class=”blueinformation”>Detailed list of<br /><%=statename%><br />Cities and Towns</a><br /><br />
<select class=”information” name=”city” onchange=”cityselection(‘<%=databaseid%>’,'<%=programid%>’,'<%=suburbcount(indexctr)%>’)”><%=cityoption%></select>
<br /><br />
<!–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>
</form>