Add text to a column in an HTML table

0

I have the following code:

<table class="TblReporte" border="1" cellSpacing="1" cellPadding="2" align="center">
  <tr>
    <td align="center">RETIRO</td>
    <td colspan="2" align="center">CAJA GENERAL</td>
    <td colspan="2" align="center">RETIRO SUCURSAL</td>
  </tr>
  <tr>
    <td border="1">NOMBRE DEL CLIENTE</td>
    <td border="1">OPERACIONES</td>
    <td border="1">MONTO</td>
    <td border="1">OPERACIONES</td>
    <td border="1">MONTO</td>
    <td border="1">COMENTARIO O JUSTIFICANTE</td>
  </tr>
  </tr>
</table>

I need to be able to add text in the comments column to later save them in my database

Example:

Do you know how I can enable this column to write?

    
asked by ARR 12.07.2018 в 18:07
source

3 answers

1

Set a input of type text where you want to have the text box.

<td border="1"><input type="text" placeholder="COMENTARIO O JUSTIFICANTE"></td>

Example:

<table class="TblReporte" border="1" cellSpacing="1" cellPadding="2" align="center">
    <tr>
      <td align="center">RETIRO</td>
      <td colspan="2" align="center">CAJA GENERAL</td>
      <td colspan="2" align="center">RETIRO SUCURSAL</td>
    </tr>
    <tr>
      <td border="1">NOMBRE DEL CLIENTE</td>
      <td border="1">OPERACIONES</td>
      <td border="1">MONTO</td>
      <td border="1">OPERACIONES</td>
      <td border="1">MONTO</td>
      <td border="1"><input type="text" placeholder="COMENTARIO O JUSTIFICANTE"></td>
    </tr>
    </tr>
  </table>
    
answered by 12.07.2018 / 18:14
source
1

What you can do is add an input inside the td to write, and differentiate it with an id to get its value in javascript

<td border="1"><input type="text" name="comentario" class = "input_comentario"></td>
    
answered by 12.07.2018 в 18:12
1

What you need involves a job that I see you do not know yet.

What you should do first is remember that HTML can not be written. For this we need the label <input> of the type "text" to make an editable field.

That input would be inside a <form> form that you would use to send the variable of <input> to a php file that makes the insertion in the database.

For example:

<form method="post" action="guardar.php">
    <table class="TblReporte" border="1" cellSpacing="1" cellPadding="2" align="center">
      <tr>
        <td align="center">RETIRO</td>
        <td colspan="2" align="center">CAJA GENERAL</td>
        <td colspan="2" align="center">RETIRO SUCURSAL</td>
      </tr>
      <tr>
        <td border="1">NOMBRE DEL CLIENTE</td>
        <td border="1">OPERACIONES</td>
        <td border="1">MONTO</td>
        <td border="1">OPERACIONES</td>
        <td border="1">MONTO</td>
        <td border="1"><input type="text" name="comentarios" id="comentarios"></td>
      </tr>
      </tr>
    </table>
<input type="submit" name="Guardar comentarios">
</form>

In the input, the comment is written and the form is executed by clicking on the button we have created.

That will send the variable "comments" to a php file where we collect the variable, we connect to the database and save it.

    
answered by 12.07.2018 в 18:14