Note that there are some explanatory texts on larger screens.

plurals
  1. POcreate and submit dynamic forms
    primarykey
    data
    text
    <p>I want to develop a webpage wich dynamically adds and removes particular webforms (all webforms with the same structure) on the page (when pressing add and remove buttons). Adding and removing the webforms already works in the code below (using a jquery function), but I still struggle to create the related unique name values when submitting more forms. My idea is: - to put all forms in an array (forms() )- each with unique name values - ...and maintain in a array (formsavailable()) which forms have been added/used and which have been removed.</p> <p>I already added the code (below) to maintain formsavailable() when adding forms. But I dont know how to code formsavailable() for removing forms.</p> <p>Any ideas? Or are there simpler ways for creating the unique name value's with the described context?</p> <p>Please your comments.</p> <p>Thank you.</p> <p>The code:</p> <pre><code>&lt;script&gt; var forms = Array(); var formsavailable = Array(); forms = getProductconfigforms(); //create a list of strings with the product forms var NUMBER_OF_FORMS = 5; for (var i=1; i&lt;=NUMBER_OF_FORMS;i++) { formsavailable[i] = true; //at the start all forms are } //script for adding and removing productss $(document).ready (function () { var i; $('.btnAdd').click (function () { i = formsavailable.indexOf(true); $('.buttons').append(forms[i]); // end append formsavailable[i] = false; $('div .btnRemove').last().click (function () { $(this).parent().last().remove(); }); // end click }); // end click }); // end ready &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt; text here &lt;/h2&gt; &lt;div class="buttons"&gt; &lt;input type="button" class="btnAdd" value="Add"&gt;&lt;br&gt; &lt;/div&gt; &lt;p&gt; tekst &lt;/p&gt; &lt;input type="button" value="Terug naar stap 1" onclick="goBack()"&gt; &lt;/body&gt; </code></pre> <p></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.
 

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