Click to See Complete Forum and Search --> : Passing multiple selected form values to another frame


valeryko
03-22-2003, 04:12 AM
I have JSP program with javascript code passing one slected value from one frame to another:

function pushLookup(menu, item) {

var value = menu.options[menu.selectedIndex].value;

if (value != '0') setValue(item, value);

}
function setValue(name, value) {

var param = eval('parent.frames["procedure"].document.forms[0].' + name);

param.value = value;

}


How can I do the same for MULTIPLE select? How to pass selected values (as array list?) to another frame?

Thank you for your help.

Val

khalidali63
03-22-2003, 07:41 AM
Something along these line will do.

run a loop through all the options in a list.Here is a function I wrote some time ago for this purpose.It would return an array of selected values 1 or many.

It takes 1 parameter beign the listbox object reference,in your case it seems to be
"menu".
In the function condition to validate for -1 referes to the first value in the list box being a statement like"select One" or "-------" something like that.
if you dont have anything that you do not want to be selected then just remove that part of the condition

&& list[x].value!="-1"

the above should be removed in that case.



function getSelectedValues(list){
var len = list.length;
var ctr=0;
var values = new Array();
for(x=0;x<len;x++){
if(list[x].selected && list[x].value!="-1"){
values[ctr] = list[x].value;
ctr++;
}
}
return values;
}


Cheers

Khalid