Click to See Complete Forum and Search --> : Updating SELECT form with array of values.


valeryko
03-25-2003, 02:15 PM
Hi,

I have a JSP program with javascript code passing slected values of a SELECT form from one frame to another.
PushLookup() creates array of selected values in one frame. SetValue() should populate SELECT form in another frame with values from this array on onClick event. It doesn't work to me somehow... ;-(

Please, help!...

function setValue(name, values) {
var param = eval('parent.frames["procedure"].document.forms[0].' + name);
var len = values.length;
for (x = 0; x < len; x++)
param[x].value = values[x].value;
}

function pushLookup(menu, item) {
var len = menu.length;
var ctr = 0;
var values = new Array();
for (x = 0; x < len; x++)
if (menu[x].selected && menu[x].value!='0'){
values[ctr] = menu[x].value;
ctr++;
}
setValue(item, values);
}

khalidali63
03-25-2003, 02:34 PM
Your code might just be doing it.But the new list box should not show anything,since you are only setting the value attribute not the text

param[x].value = values[x].value;
param[x].text= values[x].value;

this should do it..if there isn't some thing else wrong thats is not in this code snippet.

Cheers

Khalid