/    Sign up×
Community /Pin to ProfileBookmark

Pickup multiple values of a select

I have a list bos and I would like to pick up the multiple values selected.

I know that the following statement would select the one item selected.

var myindex=document.forms[0].myList.selectedIndex

I owuld like to know the statement for multiple selected items.

Thanks in advance

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@MjhLkwdSep 09.2005 — [CODE]<HTML>
<Head>
<Script Language=JavaScript>

function copyStates(isList,isForm){

stateStr = "";
for (i=1; i<isList.length; i++)
{
if (isList.options[i].selected){stateStr += isList.options[i].value+"n"}
}
isForm.selStates.value = stateStr;
}

</Script>
</Head>
<Body>
<Form name='Form1'>
<select multiple name='stateList' onChange="copyStates(this,this.form)">
<option selected> Choose the States </option>
<option value='Alaska'> Alaska </option>
<option value='Colorado'> Colorado </option>
<option value='Oregon'> Oregon </option>
</select>
<br><br>
<textarea cols='15' rows='8' name='selStates'></textarea>
<br><br>
</Form>
</Body>
</HTML>[/CODE]
×

Success!

Help @kpsarma 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.28,
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,
)...