Jump to content

Recommended Posts

i want to add a row to my end of the table but the name from the input forms needs to be different and i dont know how to increment the clone with 1 at every row added, i have this javascript code:

 

$(document).ready(function() {
  $("#addrow").click(function() {
    $('#ORDERLINES tbody>tr:last').clone(true).insertAfter('#ORDERLINES tbody>tr:last');
    return false;
  });
});

and the html

        <table id="ORDERLINES" cellspacing="1" class="tablesorter">
          <thead>
            <tr>
              <th class="center">Nr. crt</th>
              <th class="center">Denumire</th>
              <th class="center">Document justificativ Denumire/ nr./ data</th>
              <th class="center">UM</th>
              <th class="center">Cant</th>
              <th class="center">Valoare totala (lei)</th>
              <th class="center">Valoare decontata din bugetul proiectului (lei)</th>
            </tr>
          </thead>
          <tr>
            <td class="center">1</td>
            <td><input name="item_no1" type="text" id="item_no1" value="" /></td>
            <td><input name="item-desc1" type="text" id="item-desc1" value="" /></td>
            <td><input name="item-desc1" type="text" id="item-desc1" value="" /></td>
            <td><input name="item-desc1" type="text" id="item-desc1" value="" /></td>
            <td><input name="item-desc1" type="text" id="item-desc1" value="" /></td>
            <td><input name="item-desc1" type="text" id="item-desc1" value="" /></td>
          </tr>
          <tr>
            <td class="center">2</td>
            <td><input name="item_no2" type="text" id="item_no2" value="" /></td>
            <td><input name="item-desc2" type="text" id="item-desc2" value="" /></td>
            <td><input name="item-desc2" type="text" id="item-desc2" value="" /></td>
            <td><input name="item-desc2" type="text" id="item-desc2" value="" /></td>
            <td><input name="item-desc2" type="text" id="item-desc2" value="" /></td>
            <td><input name="item-desc2" type="text" id="item-desc2" value="" /></td>
          </tr>
        </table>
        <table cellspacing="1" class="tablesorter">
          <tr>
            <td colspan="5"><strong>TOTAL MATERIALE CONSUMABILE, PIESE DE SCHIMB:</strong></td>
            <td width="97"> </td>
            <td width="165"> </td>
          </tr>
        </table>
        <br />
        <p class="tright"><a id="addrow" href="#"><strong>Adauga Linie</strong></a></p>

Link to comment
https://forums.phpfreaks.com/topic/192626-java-add-row-plus-increment/
Share on other sites

var i = 0;
$(document).ready(function() {
  $("#addrow").click(function() {
    $('#ORDERLINES tbody>tr:last').clone(true).insertAfter('#ORDERLINES tbody>tr:last');
    i++;
    return false;
  });
});

Could the answer really be that simple?

I don't see any form in the given code btw

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.