Should I create a form for each row / record of this datatable?

2

In a hypothetical situation with a datatable , asynchronously a swith of ativo/inativo will be made to the registry.

Should I create a form for each row / record in that datatable? Is it semantically incorrect? Or should I manipulate the data through ids , data attributes , etc ...?

For example, this would be something like:

<table>
  <thead>
    <th>
      <td>Nome</td>
      <td>Ativo</td>
    </th>
  </thead>
  <tbody>
    <form id="1">
      <tr>
        <td>Fulano</td>
        <td>
          <input type="checkbox" name="ativo">
        </td>
      </tr>
    </form>

    <form id="2">
      <tr>
        <td>Cicrano</td>
        <td>
          <input type="checkbox" name="ativo">
        </td>
      </tr>
    </form>
  </tbody>
</table>
    
asked by anonymous 22.07.2016 / 21:05

1 answer

2

You can put your table inside the form and put name of checkbox with different names, I do not know how you will use this form later, but the right thing is to identify them with different names, I hope this helps you I do not know if this is really what you need:

<form id="formulario">
    <table>
      <thead>
        <th>
          <td>Nome</td>
          <td>Ativo</td>
        </th>
      </thead>
      <tbody>
          <tr>
            <td>Fulano</td>
            <td>
              <input type="checkbox" name="ativo1">
            </td>
          </tr>
          <tr>
            <td>Cicrano</td>
            <td>
              <input type="checkbox" name="ativo2">
            </td>
          </tr>
      </tbody>
    </table>
</form>
    
23.07.2016 / 02:41