Friday, 13 September 2013

Using Javascript/jquery how can I get values from each cells in a selected row

Using Javascript/jquery how can I get values from each cells in a selected
row

I am trying to figure out how to get and assign each cell value in a row
to a variable.In particular the check box values
Here is an example of the table
<table id="mytable" class="table">
<thead>
<b><tr><th>Header1</th><th>Header2</th><th>Header2</th><th>Header3</th></tr></b>
</thead>
<tr>
<td>value1</td>
<td>value1</td>
<td>
<label><input id="divpriority" ng-model="priority"
type="checkbox" /> Option1</label>
<label><input id="divsource" type="checkbox" />
Option2</label>
<label> <input type="checkbox"
checked/>Otion3</label>
</td>
<td><br/><br/><button id="buttonvalues" type="button"
class="btn-primary">GetValues</button></td>
</tr>
</table>
So when the "GetValues" button is clicked in the current row the values
from each cell are assigned to a variable.
I was thinking of something along the lines of this:(I know this is likely
incorrect)
$("#mytable table tbody ").on("click", "#buttonvalues", function() { var
header1; var header2; var Options = new Array()
var header1 = $(this).closest('tr').header1.val ; var header2 =
$(this).closest('tr').header2.val
Options = //Not sure what to do here
Using Javascript/jquery how can I get values from each cells in a selected
row and assign the values to a variable with the click of a button
included in the row.
Please emphasize on assigning values from the check box into an array
variable. I would like to get the name of the checkbox thats checked into
the array

No comments:

Post a Comment