Hello everyone.
I'm currently learning Javascript and doing a few exercises.
One problem I'm working on takes an array of names from an xml file using
Ajax and writes it to <select<options tags.
This is the code they use:
function writeSelect(nam e_group) {
var this_option;
var my_select = document.getEle mentById("namel ist");
for (var loop = 0; loop < name_group.leng th; loop++)
{
this_option = new Option();
this_option.val ue = the_array[loop];
this_option.tex t = the_array[loop]
my_select.optio ns[loop] = this_option;
}
}
The parameter for writeSelect() function contains the array of names and the
id "namelist" is the id for the select tag in the form element.
This is my first time seeing the new Option() function. Is this the standard
for writing arrays to the <selecttag? Or could this have been done another
way - if so what this that way?
Any response would be appreciated.
--
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forum...cript/200806/1