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

Asked

Viewed 40 times

2

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

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

To illustrate this situation, it 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>

  • that I know you can create your table within a form, do not need to separate everything

1 answer

2


You can put your table inside the form and put the name of checkbox with different names, I do not know how you will use this form later, but the right is to identify them with different names, I hope this helps you 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.