Click here to Skip to main content
15,917,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
How to Add multiple checked row data to collection in jquery?
Posted
Comments
Rajdeep Debnath 12-Dec-15 17:09pm    
Can you provide more information about the scenario....

Thank you for precision,
This code must work :

Code JAVASCRIPT :

<script>
//initialize our collection
 var items = [];
 function Selected(e) {

 var checked = $(e).is(':checked');
 var item = $(e).val();
 if (checked){
//add item to collection
    items.push(item)
  } else {
//delete item from collection
     items.pop(item)
   }
//show items
  alert(items);
 }
<script>


Code HTML :
<table>
<tr><th></th><th>Id</th></tr>
<tr><td><input type="checkbox" value="1" onclick="Selected(this)"/></td><td>1</td></tr>
<tr><td><input type="checkbox" value="2" onclick="Selected(this)"/></td><td>2</td></tr>
<tr><td><input type="checkbox" value="3" onclick="Selected(this)"/></td><td>3</td><table><tbody><tr>
</tr></tbody></table></tr></table>    
 
Share this answer
 
Pls can you more explain the process that you want ?
 
Share this answer
 
Comments
Sathish km 13-Dec-15 23:19pm    
http://jsfiddle.net/Xg56P/72/
I need like this above ex. Pass that collection value to controller method

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