View Single Post
  #17 (permalink)  
Old May 7th, 2008, 02:22 AM
joefawcett's Avatar
joefawcett joefawcett is offline
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

Firstly, as I said before, you must be clear in your mind which code executes on the server and which on the client. When you return names from the server-side code it doesn't go anywhere. You need to create the HTML that you need:
  • Code:
    var names = readDB();
    Response.Write("<script type=\"text/javascript\">\n");
    Response.Write(" var names = " + names.toString() + ";\n");
    Response.Write("</s" + "cript>\n");

  • In your client-side code don't use document.writeln, create a page as you wish with an empty select element and use the DOM to create new Option elements and add them based on the data in the names variable
  • Check the HTMl of the page created to see whether the array has been populated correctly, it should look like:
    var names= ["name1", "name2", "name3"];


Joe (Microsoft MVP - XML)
Reply With Quote