Nested table, get value of td with class i defined, but only on selected row
I desperately need help on this getting the value of a column thats nested inside a table. I cant get the logic or code right.
My table:
- <table id="eventsToList" class="table table-striped table-condensed table-responsive">
- <thead>
- <tr class="header">
- <th></th>
- <th>EventID</th>
- <th>Created</th>
- <th>Description</th>
- <th class="pull-left">Address</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><input type='checkbox' id='eventSelect' /></td>
- <td>%php code show EventID%</td>
- <td>%php code show EventStartDate%</td>
- <td>%php code show Description%</td>
- <td>%php code % show ServiceAddress%</td>
-
- <td>
- <table id="productList">
- <th>
- <tr>
- <td>%php code% show ProductName</td>";
- <td class='totalDiv pull-right'>%php code show Total%</td>";
- </tr>
- </table
- </td>
- </tr>
- </tbody>
- </table>
-
My code :
- $('#eventsToList').click(function () {
- $('input[type=checkbox]').each(function () {
- if ($(this).is(":checked"))
- {
- $(".totalDiv").each(function() {
-
- });
- }
- });
- //save total to input box
- });
Here is one of my many attempts, it loops through all the <td> elements with the totalDiv class even if they are not in the selected row . I just want to get the value of <td> elements of the selected row where the class is totalDiv, and I want to allow the user to select any number of rows from the main table. I will save the total in an element after each click
Its ultimately building an invoice.I want to be clear on what the fix is so I prefer not use plugins, as I am trying to get better at this, I have tried for hours to figure this out on my own and would be very happy for any help.