Note that there are some explanatory texts on larger screens.

plurals
  1. POfunctions doesnt work on dynamically added form fields
    primarykey
    data
    text
    <p>I created form with 2 fields where user can add values for generate rectangular div with his values. </p> <pre><code> &lt;form&gt; &lt;fieldset class="fieldset"&gt;1 &lt;input type="text" id="test" name="test" /&gt;2 &lt;input type="text" id="test2" name="test" /&gt; &lt;/fieldset&gt; &lt;input type="button" id="add_new" value="add new"&gt; &lt;/form&gt; &lt;div id="dimensions"&gt;&lt;/div&gt; &lt;div id="trouble"&gt;&lt;/div&gt; &lt;div id="texte"&gt;&lt;/div&gt; </code></pre> <p>Everything work perfect, but now I add some functionality to dynamically adding more fieldsets with forms. And I want to draw rectangle div for each fieldset with form fiels. When I type values 100x200px in first row jquery will draw div with these dimensions, but when Im typing in second or third fieldset, div will be redrawn with values from another fieldset.. I dont know why these values from dynamically added fieldset are not working.</p> <pre><code>$(document).ready(function () { var fieldset_parent = $(".fieldset:eq(0)").clone(); $(document).on("click", "input#add_new", function () { $("fieldset:last").after($(fieldset_parent).clone()); }); $("#test, #test2").keyup(function () { var width = parseInt($("#test").val()); var height = parseInt($("#test2").val()); var max = 200; var min = 20; var ratio; if (width &gt;= height) { $("#trouble").html("Width bigger"); ratio = max / width; width = ratio * width; height = height * ratio; } else { $("#trouble").html("height bigger"); ratio = max / height; height = ratio * height; width = width * ratio; }; $("#dimensions").html(width + " x " + height); $("#texte").css({ "width": width + "px", "height": height + "px" }); }); }); </code></pre> <p><a href="http://jsfiddle.net/xzGXF/" rel="nofollow">And here is my code of fiddle</a></p> <p>thanks a lot for your help</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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