Note that there are some explanatory texts on larger screens.

plurals
  1. POCloning empty form fields
    primarykey
    data
    text
    <p>I am still attempting to create blank fields that users can add on the fly. I am attempting to clone the following hidden template but I can't get it to add.</p> <p>My HTML</p> <pre><code> &lt;div class="_100"&gt; &lt;fieldset id="FieldBlank"&gt; &lt;div id="readroot" class="hidden"&gt; &lt;div class="_100"&gt; &lt;div class="_50"&gt; QA Sample ID:&lt;input type="text" id="QASampleID" name="QASampleID"&gt;&lt;/div&gt; &lt;div class="_50" data-role="controlgroup" data-mini="true" data-type="horizontal"&gt; &lt;label&gt;Collection Method&lt;/label&gt;&lt;br /&gt; &lt;input type="radio" id="radGrab1" value="Grab" name="Collection1" /&gt; &lt;label for="radGrab1"&gt;Grab&lt;/label&gt; &lt;input type="radio" id="radEWI1" value="EWI" name="Collection1" /&gt; &lt;label for="radEWI1"&gt;EWI&lt;/label&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="_100"&gt; &lt;div class="_40"&gt; &lt;label class="analysis-label" for="analysis"&gt;Analyte:&lt;/label&gt; &lt;select class="analysis" id="analysis" name="analysis" data-iconpos="left" data-icon="grid"&gt; &lt;option&gt;Select&lt;/option&gt; &lt;option value = "TN"&gt;TN&lt;/option&gt; &lt;option value = "TP,NO2+3"&gt;TP,NO2+3&lt;/option&gt; &lt;/select&gt;&lt;/div&gt; &lt;div class="_30"&gt; &lt;label class="preserve-label" for="preserve"&gt;Preserved&lt;/label&gt; &lt;select class="select_preserve" id="preserve" name="preserve" data-iconpos="left" data-icon="grid"&gt; &lt;option&gt;Select&lt;/option&gt; &lt;option value = "HNO3"&gt;HNO&amp;#8323;&lt;/option&gt; &lt;option value = "H2SO4"&gt;H&amp;#8322;SO&amp;#8324;&lt;/option&gt; &lt;/select&gt;&lt;/div&gt; &lt;div class="_30"&gt; &lt;label class="cool-label" for="cool"&gt;Cooled&lt;/label&gt; &lt;select class="select_cool" id="cool" name="cool" data-iconpos="left" data-icon="grid"&gt; &lt;option&gt;Select&lt;/option&gt; &lt;option value = "Ice"&gt;Ice&lt;/option&gt; &lt;option value = "Frozen"&gt;Frozen&lt;/option&gt; &lt;option value = "None"&gt;None&lt;/option&gt; &lt;/select&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;button type="button" data-theme="b" data-icon="plus" id="moreFields" onclick="moreFields()"&gt;ADD FIELD BLANK&lt;/button&gt; &lt;hr /&gt;&lt;div id="writeroot"&gt; &lt;/div&gt; </code></pre> <p>My javascript</p> <pre><code>var counter = 0; function moreFields() { counter++; var newFields = document.getElementById('readroot').cloneNode(true); newFields.id = ''; newFields.style.display = 'block'; var newField = newFields.childNodes; for (var i = 0; i &lt; newField.length; i++) { var theName = newField[i].name if (theName) newField[i].name = theName + counter; } var insertHere = document.getElementById('writeroot'); insertHere.parentNode.insertBefore(newFields,insertHere); } </code></pre> <p>I just cannot get it to work! Is it because this script is not jquery? It doesn't seem to be because it is hidden because when I unhide it the button still doesn't work to add the clones? I am so pulling my hair out right now. I need you 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.
 

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