-
Array and selected dropdowns
hi
Hoping someone can help with this code, I'm looking for the array to check against the specified country "countrycheck" if its the same, then the dropdown is set as selected for that country.
The reason for this, is that the countrycheck will be pulled from a database.
Anyway, I cant get it to work - can anybody help?? Thanks
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
var countryarray = new Array("BE","DE","DK","ES","FI","FR","ITL","NL","NO","SE","UK","ZA")
var assigneeshow
var myfront
var mymiddle
var myend
countrycheck = 0;
countrycheck = "UK"
myfront = "<OPTION value="
mymiddle = "SELECTED>"
myend = "</OPTION>"
%>
<SELECT name="Country">
<%
for(i=0; i<countryarray.length; i++)
{
if (countrycheck == countryarray[i])
{
document.write (myfront & countryarray[i] & mymiddle & countryarray[i] & myend)
}
else
{
document.write (myfront & countryarray[i] & ">" & countryarray[i] & myend)
}
}
%>
</SELECT>
</body>
</html>
-
It looks like your missing a space so the browser wont be parsing it correctly
try mymiddle = " SELECTED>"
also if you're going to be strict about the syntax use it like this
<option value="UK" selected="selected">
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules