Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set ids and names values?
    primarykey
    data
    text
    <p>I make a dynamic form but when i insert fields dynamically,names and ids not changed properly.</p> <p>Here is my code:</p> <pre><code>&lt;div id="dataRows"&gt; &lt;div class="fieldRow" id="template"&gt; &lt;select class="items" name="items{{counter}}" id="items{{counter}}" style="width:127px; float:left;"&gt;&lt;option value="1" selected="selected" disabled="disabled"&gt;&lt;/option&gt;&lt;/select&gt; &lt;textarea name="description{{counter}}" id="description{{counter}}" class="description" style="float:left; display: block; height: 30px; width:209px; border-radius:0px; margin: -1px 1px 0;"&gt;&lt;/textarea&gt; &lt;input type="text" name="unitprice{{counter}}" id="unitprice{{counter}}" class="unitprice" style="float:left; display: block; height: 30px; width:106px; border-radius:0px; margin: -1px -1px 0;"&gt; &lt;input type="text" name="quantity{{counter}}" id="quantity{{counter}}" class="quantity" style="float:left; display: block; height: 30px; width:64px; border-radius:0px; margin: -1px 1px 0;"&gt; &lt;select name="firsttax{{counter}}" id="firsttax{{counter}}" style=" float:left; display: block; height: 31px; width:106px; border-radius:0px; margin: -2px -1px 0;"&gt;&lt;option value="1" selected="selected" &gt;&lt;/option&gt;&lt;/select&gt; &lt;select name="secondtax{{counter}}" id="secondtax{{counter}}" style="float:left; display: block; height: 31px; width:107px; border-radius:0px; margin: -2px 0px 0;"&gt;&lt;option value="1" selected="selected"&gt;&lt;/option&gt;&lt;/select&gt; &lt;input type="text" name="linetotal{{counter}}" id="linetotal{{counter}}" class="linetotal" placeholder="0.00" readonly style="float:right; display: block; height: 31px; width:107px; border-radius:0px; background-color: #F0F0F0; text-align:right; margin: -31px -1px 0;"&gt; &lt;input type="button" class="button remove" id="btnDel" value="Remove Row" style="float:right; margin:-29px -110px; color: #ffffff; background-color: #d9534f; border-color: #d43f3a; padding: 3px 10px; margin-bottom: 0; font-size: 14px; font-weight: normal; line-height: 1.428571429; text-align: center; white-space: nowrap; vertical-align: middle; cursor: pointer; border:1px solid transparent; border-radius: 4px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none;" /&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and here is my java script code for dynamic fields:</p> <pre><code>jQuery(document).on("ready", function () { initAddRows(); }); function initAddRows() { var template = jQuery("#template"), dataRows = jQuery("#dataRows") jQuery("#btnAdd").on("click", function () { var newRow = template.clone(true, true), fieldRows = dataRows.find(".fieldRow"), rowNumber = fieldRows.length + { { counter } }; newRow.attr('id', 'row' + rowNumber).find('[id]').each(function () { jQuery(this).attr("id", jQuery(this).attr("id") + rowNumber); jQuery(this).attr("name", jQuery(this).attr("name") + rowNumber); $('#itemscounter').val(+rowNumber); }); fieldRows.filter(":last").after(newRow); }); } </code></pre> <p>my field values are items9,description9 and my {{counter}}=9,when i generate fields the names of fields are items910,description910 but i want the names and ids are items10,description10.</p> <p>How i do this?</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