/    Sign up×
Community /Pin to ProfileBookmark

Passing multiple selected form values to another frame

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

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63Mar 22.2003 — 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.


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


Cheers

Khalid
×

Success!

Help @valeryko spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...