Click here to Skip to main content
15,885,868 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a button .it is bind the data from database.

For example it has 30buttons the values like 1,2,3.....30.

when a user select 4buttons means the values should be like this 25,27,24,22.

How this things can happen.

What I have tried:

I tried with a label but it shows only one value

The user click the next button means that button value only shown.
Posted
Updated 18-Jan-17 11:45am
Comments
Sunasara Imdadhusen 17-Jan-17 6:16am    
not clear? provide more detail with code snippet
Member 12857356 17-Jan-17 6:27am    
Am using a button which is inside the datalist
The datalist ehich is inside the gridview.
I want to change the button color which is in the datalist
Sinisa Hajnal 17-Jan-17 8:40am    
Why don't you use checkboxes? It seems more natural that way

1 solution

you can use the jquery to get all the selected checkboxes and the associated values,

JavaScript
<pre>function getValueUsingClass(){
	/* declare an checkbox array */
	var chkArray = [];
	
	/* look for all checkboes that have a class 'chk' attached to it and check if it was checked */
	$(".chk:checked").each(function() {
		chkArray.push($(this).val());
	});
	
	/* we join the array separated by the comma */
	var selected;
	selected = chkArray.join(',') + ",";
	
	/* check if there is selected checkboxes, by default the length is 1 as it contains one single comma */
	if(selected.length > 1){
		alert("You have selected " + selected);	
	}else{
		alert("Please at least one of the checkbox");	
	}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900