I cann't unable to get count the selected list box items using javascript

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Dec 2007
Posts: 9
Reputation: palcham is an unknown quantity at this point 
Solved Threads: 0
palcham palcham is offline Offline
Newbie Poster

I cann't unable to get count the selected list box items using javascript

 
0
  #1
Jan 2nd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3
Reputation: AOlevel1 is an unknown quantity at this point 
Solved Threads: 1
AOlevel1 AOlevel1 is offline Offline
Newbie Poster

Re: I cann't unable to get count the selected list box items using javascript

 
0
  #2
Jan 2nd, 2008
I think you are looking for one of these:

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

OR

document.getElementById('SelectId').selectedIndex;
Last edited by AOlevel1; Jan 2nd, 2008 at 11:12 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,648
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: I cann't unable to get count the selected list box items using javascript

 
0
  #3
Jan 2nd, 2008
Try something like:
  1. /**
  2.  * Alerts out the selected item values of a select box
  3.  *
  4.  * @author sos
  5.  * @param {HTMLFormElement} frm The reference to the form element
  6.  * @param {String} name The name of the select box
  7.  */
  8. function show(frm, name) {
  9. var selOpts = frm.elements[name].options;
  10. for(var i = 0, max = selOpts.length; i < max; ++i) {
  11. if(selOpts[i].selected) {
  12. alert("Selected Item: " + selOpts[i].value);
  13. }
  14. }
  15. }
Last edited by ~s.o.s~; Jan 2nd, 2008 at 11:30 am.
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 9
Reputation: palcham is an unknown quantity at this point 
Solved Threads: 0
palcham palcham is offline Offline
Newbie Poster

Re: I cann't unable to get count the selected list box items using javascript

 
0
  #4
Jan 3rd, 2008
Hi

Your sent coding is very useful

very thanks to you
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC