Results 1 to 2 of 2

Thread: Array and selected dropdowns

  1. #1
    Join Date
    Oct 2005

    Cool Array and selected dropdowns


    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

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    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)
    document.write (myfront & countryarray[i] & ">" & countryarray[i] & myend)


  2. #2
    Join Date
    Jan 2006
    Manchester England UK
    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