Hi JS Gurus, Could you please help fix the following issue. I have an asp (classic) page where a <select> element is filled with javascript arrays. I need to make a country of my choice, say Japan, preselected. Please let me know how can I do this using the following code: <% function getCountries(regionId) dim adoRs,sqlStr,temp temp="" sqlStr="select countryId from tblCountry where regionId=" & regionId set adoRs=server.CreateObject("ADODB.recordset") adoRs.Open sqlStr,strConn,adOpenForwardOnly,adLockOptimistic do while not(adoRs.EOF) temp=temp & adoRs("countryId") & "," adoRs.movenext loop adoRs.close set adoRs=nothing if len(temp)>0 then temp=left(temp,len(temp)-1) end if getCountries=temp end function %> [B][I]Following is <select> element being filled with js array;[/I][/B] <select name="countryId" class=searchbycountry onclick="javascript:if(this.length<=1){window.alert('Please choose a Region before selecting a Country of Destination.');document.form1.regionId.focus();}" onChange="javascript:OnCountryChange();" onFocus="javascript:this.style.backgroundColor='#ffff66';" onBlur="javascript:this.style.backgroundColor='#ffffff';"><option value="">Select a Destination Country</option></select> [B][I]At the end of the page following code is written which does the actual filling:[/I][/B] <script language="javascript"> <!-- var aRegion = new Array; var aCountry = new Array; var catCountry = new Array; var catCity = new Array; var aCity = new Array; <% Dim adoRs,SQLString Set adoRs=Server.CreateObject("ADODB.RecordSet") SQLString="select regionId,name from tblRegion" adoRs.Open SQLString,strConn,adOpenForwardOnly,adLockOptimistic while not(adoRs.EOF or adoRs.BOF) %> aRegion[<%=adoRs("regionId")%>]="<%=adoRs("name")%>"; catCountry[<%=adoRs("regionId")%>]=[<%=getCountries(adoRs("regionId"))%>]; <% adoRs.MoveNext wend adoRs.Close %> Code (markup): In the above catCountry fills the country dropdown. Please help to make a country pre-selected. Any help will be greatly appreciated. regards, manualauto
1. there's an asp forum 2. best practice here is to not rely on js for this - in your DB interaction, where you read the countries, you may as well read your selected/current one and then build the <option> elements with a selected='selected' for the relevant line, FROM ASP.