Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

401
Views
How to get row and column name of a selected checkbox inside a table cell using javascript

When I select a checkbox, it should give me the time (row) and day (column) value using javascript. If possible I should put these selected values into two separate arrays for time and day.

For example:

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

$("input[type=checkbox]").change(function() {
    if (this.checked) {
        let checkedCol = this.closest('tr').cells[0];
        let time = checkedCol.textContent;
        let colInd = parseInt($(this).parent().index());
        let day = $(this).closest('table').find('tr:first').find("td").eq(colInd).text();
        alert("Time : " + time + "  Day : " + day);
    }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr>
  <td></td>
  <td>Mon</td>
  <td>Tue</td>
</tr>
<tr>
  <td>8-12</td>
  <td><input type="checkbox" name="" value="1"></td>
  <td><input type="checkbox" name="" value="1"></td>
</tr>
<tr>
  <td>12-17</td>
  <td><input type="checkbox" name="" value="1"></td>
  <td><input type="checkbox" name="" value="1"></td>
</tr>
</table>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!