Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery - dynamically added input field doesn't send value to post
    primarykey
    data
    text
    <p>I have this particular jquery code to add/remove fields on a form and then send its values: </p> <pre><code>$(document).ready(function() { $("#add").click(function() { var intId = $("#reglas div").length + 1; var fieldWrapper = $('&lt;div class="fieldwrapper" id="field' + intId + '"/&gt;'); var fName = $('&lt;input align="left" type="text" placeholder="Path" class="reglas_wrapper" id="path" name="field1_' + intId + '" required /&gt; '); var fName2 = $('&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(fName); fieldWrapper.append(fName2); 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>In which you can add/remove fields on the Cache section but the form sends every value except those which were added dynamically.</p> <p>How can I solve it? You can see the posted form data with Firebug.</p> <p>Here is a JS Fiddle for you: <a href="http://jsfiddle.net/34rYv/121/" rel="nofollow">http://jsfiddle.net/34rYv/121/</a></p> <p>Also I realized that when I delete fields, its name doesn't rename. Maybe you can help me with this too :)</p> <p>Thanks in advance Nicolas</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.
 

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