Note that there are some explanatory texts on larger screens.

plurals
  1. PORenaming form fields added or deleted dynamically
    primarykey
    data
    text
    <p>I'm looking for help to rename the name attributes of some fields created dynamically. Now, my code assigns new values to the added fields (it increments according to the length of the div) but the problem appears when I delete a field, I don't know how to rename the remaining according to the number of fields deleted.</p> <p><strong>jQuery:</strong></p> <pre><code>$(document).ready(function () { $("#add").click(function () { var intId = $("#reglas div").length; var fieldWrapper = $('&lt;div&gt;&lt;/div&gt;', { class: 'fieldwrapper', id: 'field' + intId }); var fPath = $('&lt;input align="left" type="text" placeholder="Path" class="reglas_wrapper" id="path" name="field1_' + intId + '" required /&gt; '); var fTTL = $('&lt;input type="text" class="reglas_wrapper" placeholder="TTL" id="ttl" name="field2_' + intId + '" required /&gt;'); var removeButton = $('&lt;input align="right" type="button" id="del" class="remove" value="-" /&gt; &lt;br&gt;&lt;br&gt;'); removeButton.click(function () { $(this).parent().remove(); }); fieldWrapper.append(fPath); fieldWrapper.append(fTTL); fieldWrapper.append(removeButton); $("#reglas").append(fieldWrapper); }); $("#cache").each(function () { $(this).qtip({ content: { text: $(this).next('.tooltiptext') } }); }); }); $('#formsite').on('submit', function (e) { //prevent the default submithandling e.preventDefault(); //send the data of 'this' (the matched form) to yourURL $.post('siteform.php', $(this).serialize()); }); </code></pre> <p>HERE'S MY FULL CODE: <a href="http://jsfiddle.net/34rYv/131/" rel="nofollow">http://jsfiddle.net/34rYv/131/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload