Add text entered in an html table

0

I have home.html

Nombre: <input type="text" id="nombre">
<button type="button" id="add">Agregar</button>

<table id="test">
  <thead>
    <tr>
      <th>Nombre</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td class="espacioNomb">

      </td>
      <td class="espacioNomb">

      </td>
    </tr>
  </tbody>
</table>

What you want to do is that when you enter a name in input, I insert it in the <td class="espacioNomb">

This is what I was doing but the information does not arrive at the table of testing.html

$("#add").on("click", function(){
  $('#test > tbody').append('<tr><td>'+$("#nombre").val());
});
    
asked by Eduard Zora 24.04.2017 в 16:12
source

1 answer

0

The problem is that home.html is a page, and testing.html is another page.

Therefore with the script it is running only in testing.html and therefore it does not find certain variables that lie on the page home.html .

What you can do is make a shipment from home.html by means of javascript to testing.html , and when loading, retrieve that data and store it in the respective boxes that are needed.

Either every time you save in the home.html page you store it in a variable and once you're ready with this, you send it by ajax or by window.location passing it as a parameter that variable that can be a JSON

I hope this will guide you in a better way. Success in your project!

    
answered by 24.04.2017 в 16:34