/    Sign up×
Community /Pin to ProfileBookmark

How does JS handle Multiple Select box?

I have a multiple select box in following.

[CODE]
<select name=test[] size=5 multiple>
<option value=item1 >item1</option>
<option value=item2 >item2</option>
<option value=item3 >item3</option>
</select>
[/CODE]

What I want is when I select any option, it will show the value of it in other HTML part (let’s say “show box”), if I un-select it, the value of it will be disappeared from “show box”.

Can you give me any hint about it? Thank you

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisMay 16.2007 — Each option that is selected has its "selected" property set to true.<i>
</i>// clear the HTML box first!
for (var i=0; i&lt;document.formName.selectName.options.length; i++)
{if (document.formName.selectName.options[i].selected)
{// add the value to your HTML box}
}
×

Success!

Help @sunnyside 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.19,
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,
)...