This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes How to get total count of selected Items of <Select> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to get total count of selected Items of <Select>" Watch "How to get total count of selected Items of <Select>" New topic
Author

How to get total count of selected Items of <Select>

ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 228
HI ,
How to get all index of selected items in multiselect box
<select name="s1" multiple>
<option value"1">one</option>
<option value"2">two</option>
<option value"3">three</option>
<option value"4">four</option></select>

suppose i am selecting all four iteam then how can i get index of all selected items??

selectedIndex retruns only first element selected...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Iterate over the options looking for those with the selected attribute.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ravindra patil
Ranch Hand

Joined: Sep 01, 2006
Posts: 228
thanks ...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to get total count of selected Items of <Select>
 
Similar Threads
Firefox doesn't show background color for selected option
How to set Default selection in h:selectOneMenu
Replacing the drop down box to text field
ComoboBox values
Getting an Option object from Select Object using JavaScript