0

Hi

I cann't unable to get count the selected list box items using javascript so you please help me.
if you know means please send to me

Advance thanks

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by palcham
0

I think you are looking for one of these:

document.getElementById('SelectId').options.length;

OR

document.getElementById('SelectId').selectedIndex;

0

Try something like:

/**
 * Alerts out the selected item values of a select box
 *
 * @author sos
 * @param {HTMLFormElement} frm The reference to the form element
 * @param {String} name The name of the select box
 */
function show(frm, name) {
  var selOpts = frm.elements[name].options;
  for(var i = 0, max = selOpts.length; i < max; ++i) {
    if(selOpts[i].selected) {
      alert("Selected Item: " + selOpts[i].value);
    }
  }
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.