|
populate an array from a select option list
hi, i am trying to populate an array from a select box. Users select an item from the option list then they click the button below. The aim is to write to the text area what they have selected.
<p align=center><INPUT TYPE="button" VALUE="Add selection to list" NAME="Adder" onclick="compilelist()";>
function compilelist()
{
document.form1.text1.value=window.parent.returnlist();
}
. . . .(window.parent)
var showlist= new Array();
function returnlist()
{
var returnValue = "List so far\n";
var listindex;
var noofoptions=showlist.length;
for (listindex=0; listindex<noofoptions; listindex++)
{
returnValue = returnValue + showlist[listindex] + "\n";
}
return returnValue;
var findselected = window.frames["Rightside"].document.form1.oplist1.selectedIndex;
var textofselected = window.frames["Rightside"].document.form1.oplist1.options[findselected].text;
var valofselected = window.frames["Rightside"].document.form1.oplist1.options[findselected].value;
showlist[showlist.length] = textofselected
return true;
}
i have already been able to write to the text area but without making an array . . .like this:
function compilelist()
{
var findselected = document.form1.oplist1.selectedIndex;
var textofselected = document.form1.oplist1.options[findselected].text;
var valofselected = document.form1.oplist1.options[findselected].value;
var keeprevious=document.form1.text1.value;
document.form1.text1.value=keeprevious + textofselected + " " + valofselected + "\n";
}
the problem with this technique is that i am limited for my options to be able to sort what i have written to the text box. i have to be able to add each selection as 1 array entry but i have no idea how. the code i have written to attempt this probly makes this clear.
Can anyone suggest any way how this is possible please.? Thanks
|