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

Recommended Answers

All 3 Replies

I think you are looking for one of these:

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

OR

document.getElementById('SelectId').selectedIndex;

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);
    }
  }
}

Hi

Your sent coding is very useful

very thanks to you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.