/    Sign up×
Community /Pin to ProfileBookmark

Selections Chosen For a Multi Select Combo Box

Hi,
If I have a multi select combo box, that is with the ability to chose more than one option how in Javascript can I get a handle on the values selected by the user?

If the user chose the first three options from the following combo box I know that:

document.form1.ProductGroup.options[document.form1.ProductGroup.selectedIndex].value

would return 11, but how can I get a handle on what was really selected eg(11,4, and 9)?

Does anyone know?

<select MULTIPLE size=”3″ name=”ProductGroup” class=”TextFields” onchange=”” disabled>
<option value=”11″>Esignal</option>
<option value=”4″>FoxTrader </option>
<option value=”9″>General</option>
<option value=”6″>Hubb</option>
<option value=”10″>Optionetics</option>
<option value=”12″>Publications</option>
<option value=”7″>Safety in the Market</option>
<option value=”5″>ShareAnalyser</option>
<option value=”8″>Sherpa</option>
</select>

Thanks
Andrew

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@cyber1Aug 26.2005 — Heres an example.

-Bill

[CODE]
<html>
<head>
<title>Untitled Test</title>
<meta name="generator" content="BBEdit">

<script language="JavaScript">
<!--
function seeList(form){
var result ="";
for (var i = 0; i < form.ProductGroup.length; i++){
if (form.ProductGroup.options[i].selected){
result += "n " + form.ProductGroup.options[i].value
}
}
alert("you have selected:" +result)
}

// -->
</SCRIPT>
</head>

<body>

<select MULTIPLE size="6" name="ProductGroup" class="TextFields">
<option value="11">Esignal</option>
<option value="4">FoxTrader </option>
<option value="9">General</option>
<option value="6">Hubb</option>
<option value="10">Optionetics</option>
<option value="12">Publications</option>
<option value="7">Safety in the Market</option>
<option value="5">ShareAnalyser</option>
<option value="8">Sherpa</option>
</select>
<input type="button" value='Submit' onclick="seeList(this.form)">

</form>

</body>
</html>
[/CODE]
×

Success!

Help @frudd 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.16,
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,
)...