Link to home
Start Free TrialLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

looping through set of checkbox using jquery

Hello Experts,
Can someone of you please let me know is there any error in the attached snippet?
I am trying to loop through the set of check boxes in the page and show all the checked values in an alert. It is over writing the value with the first checkbox selected to the rest.
I am probably doing something wrong here .
Please advice
Regards
s
function addToList(){
   if($("#drpLists").val() == 0){
		alert('Please select a list');
   }else{           
		var result = "";                        
       $(".chkRefNos").each( function () {
       if(this.checked == true){
			alert($(".chkRefNos:checked").val());
			result = result + $(".chkRefNos:checked").val() + ", ";
       }                        
       });
//alert(result);
   };                 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of - -
- -
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of newbie27

ASKER

thanks, that worked...