mercredi 18 septembre 2019

Check checkbox in table when click on table cell next to it

I have a table with rows that look like this: ( 'o' is a checkbox)

_________________________________________
| o |  some label  | textarea  |    o    |
|___|______________|___________|_________|

this is it's code:

<table class="table table-condensed table-bordered>
  @foreach ($labels as $label) 
    <tr>
      <td class="checkbox"><input type="checkbox" name="checkbox-one /> 
      <td></td>
      <td class="with-textarea"><textarea></textarea></td>
      <td class="checkbox"><input type="checkbox"  name="checkbox-two" /></td> 
    </tr>
  @foreach
</table>

How can I achieve that the left checkbox is checked when the user clicks either it or on 'some label' next to it?

I know I need javascript for it, but I don't have much knowledge.
Other similar questions were either really old or didn't help me further.




Aucun commentaire:

Enregistrer un commentaire