Array of Strings and outputting it into a drop-down list

Hi,

I have a javascript function that returns an array of information. From this Array, I want to plug the information into a drop-down list inside a table. How can I do this.

function myfunction(){

Array a = new Array();

//more codes...

return a;

}

<HTML>

<BODY>

<TABLE>

<TR>

<TD>

Please select:

</TD>

<TD>

// I want to create a drop-down list here with the information from the array returned from the function above.

</TD>

</TR>

</TABLE>

</BODY>

</HTML>

[624 byte] By [KY8a] at [2007-11-27 11:42:25]
# 1

Java != Javascript

You can find several examples in the net just google

manuel.leiriaa at 2007-7-29 17:44:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Unfortunately, it is a javascript function.

And yes, instead of "Array a = new Array()", it is:

var a = new Array()

thanks!

KY8a at 2007-7-29 17:44:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

var valarray=getVal.split(",");

for (var i=0; i < valarray.length;++i){

addOption(document.getElementById("<second combo box name here>"), valarray[i], valarray[i]);

}

function trim(stringToTrim) {

return stringToTrim.replace(/^\s+|\s+$/g,"");

}

function addOption(selectbox,text,value)

{

var optn = document.createElement("OPTION");

optn.text = trim(text);

optn.value = trim(value);

selectbox.options.add(optn);

}

function removeAllOptions(selectbox)

{

var i;

for(i=selectbox.options.length-1;i>=0;i--)

{

selectbox.remove(i);

}

}

skp71a at 2007-7-29 17:44:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...