/    Sign up×
Community /Pin to ProfileBookmark

auto-selecting multiple select values upon submit

I have a situation (don’t we all?) in which I am moving the contents of one multiple select to another. This works great. But when I submit the form, the contents of the second are not recognized. This is because they are not ‘selected’ when the form is submitted. They have to be manually selected for the action template to recognize their existence, but as everyone surely knows, clients (those pesky people who pay our bills) don’t think this is terribly intuitive. So my situation (yes, I still have one) is that I need to dynamically select the contents of this second multiple select when the form is submitted.

Surely a simple exercise in javascript, but since I don’t actually think in this language, I’m not sure how to go about it. About as far as I can get is that it needs to be an onSubmit event.

Thanks for any suggestions.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63May 11.2003 — Presuming that you want to select all of the option values in the list box,and the form name is "form1" listbox name is "lb_2"

here is the javascript that will select all of the options, just call this function before you submit.

function Process(){

var listBox = document.form1.lb_2;

var len = listBox.length;

for(var x=0;x<len;x++){

listBox.options[x].selected= true;

}

}
Copy linkTweet thisAlerts:
@GoldDogauthorMay 11.2003 — That was the answer. Thanks Khalid.
Copy linkTweet thisAlerts:
@khalidali63May 11.2003 — You are welcome ..?
×

Success!

Help @GoldDog 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.9,
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,
)...