Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't manage to get working dynamic form with Jquery
    primarykey
    data
    text
    <p>I'm making a dynamic html form with jQuery.<br> It is a form for measuring air in each room for ventilation.</p> <p>I need two inputs: Room name and Air volume value.<br> My task is to dynamically add a line with Select and Input and Remove buttons. Later on it should be submitted to the php processor. </p> <p>My plan was to clone div and it looked that it works, but I get problems with Select input field.<br> Select menu in the original Div works, but the i clone div Select value would't change. I was looking around for the solution, but I haven't managed to find out. By pressing remove button I need to remove current DIV with elements. That doesn't work either:)</p> <p>I'm not sure if I'm in correct way of making all that happen, because I'm just starting out with jQuery.<br> Thanks for any help!</p> <p>Here is the code for the form:</p> <pre><code>&lt;head&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.8.2.min.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function Addonemoretilluft() { $('#tilluft_line').clone().insertAfter("#tilluft_line"); } function Removetilluft() { $('#page').remove("#tilluft_line"); } $(document).ready(function() { $("#add_tilluft").click(function(){ Addonemoretilluft(); }); $("#remove_tilluft").click(function(){ Removetilluft(); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="page" data-iscroll="" id="page"&gt; &lt;form action="handle.php" method="post" data-ajax="false" id="tilluft_form"&gt; &lt;div id="tilluft_line" class="ui-grid-b"&gt; &lt;div id="select_value" class="ui-block-a"&gt; &lt;select name="tilluft_name[]" id="tilluft_name[]" data-mini="true"&gt; &lt;option value="val1"&gt;Val 1&lt;/option&gt; &lt;option value="val2"&gt;Val 2&lt;/option&gt; &lt;option value="val3"&gt;Val 3&lt;/option&gt; &lt;option value="val4"&gt;Val 4&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div id="input_value" class="ui-block-b"&gt; &lt;input name="tilluft_value[]" id="tilluft_value[]" data-mini="true"&gt; &lt;/div&gt; &lt;div class="ui-block-c" style="width:35px;"&gt; &lt;a href="#" id="remove_tilluft" data-role="button" data-icon="delete" data-iconpos="notext"&gt;Delete&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;a id="add_tilluft" href="#" data-role="button" data-icon="add" data-mini="true" data-inline="true"&gt;Add one more&lt;/a&gt; &lt;/form&gt; &lt;input type="submit" form="tilluft_form" value="Submit Form" data-mini="true" data-inline="true"/&gt; &lt;/div&gt;​ &lt;/body&gt; </code></pre> <p>Test version <a href="http://jsfiddle.net/D4MPu/" rel="nofollow">http://jsfiddle.net/D4MPu/</a></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