By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

How to retrieve multiple values from html:select tag.

P: 2
In my project, there is a single select tag,

<html:select property="userName" size="7">
<html:options collection="UserList" property="value" labelProperty="label" />
</html:select>
<br><br>
<input type="button" value="Select" onClick="go()">&nbsp;&nbsp;&nbsp;
<input type="button" value="Cancel" onClick="cancel()">

when user choose any one and click "select" button, the value will be transfered to original window:

function go() {
var aform = document.forms[0];
var bform = window.opener.document.forms[0];

bform.userName.value=aform.userName.value

window.close();
}


Now I need to make it able to choose multiple values, so I can concatenate it and transfer to original window, how do I retrieve multiple values ? Thanks.

<html:select property="userName" size="7" multiple="true">
<html:options collection="UserList" property="value" labelProperty="label" />
</html:select>
<br><br>
<input type="button" value="Select" onClick="go()">&nbsp;&nbsp;&nbsp;
<input type="button" value="Cancel" onClick="cancel()">
Sep 29 '06 #1
Share this Question
Share on Google+
1 Reply


P: 2
Find the answer myself, use userName.options.length and userName.options[i].selected to do the loop and processing.
Sep 30 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.