0

我正在尝试克隆具有选择而不克隆输入的字段集。(我需要空白)。我在表单的正文中创建了一个隐藏的字段集,但不是表单本身,但我似乎无法让它工作

 <div id="analyte" style="display: none">
 <div class="_40">
 <label class="analyte-label" for="analyte">Analyte:</label>
    <input class="analyte" type="text" id="analyte1" name="analyte" value=""> </div>
 <div class="_30">
     <label class="preserved-label" for="preserved">Preserved</label>
 <select class="select_preserved" id="preserved1" name="preserved" data-iconpos="left" data-icon="grid" data-native-menu="false" >
        <option value = ""></option>
           <option value = "HNO3">HNO&#8323;</sub></option>
           <option value = "H2SO4">H&#8322;SO&#8324;</option>
           <option value = "H3PO4">H&#8323;PO&#8324;</option>
           <option value = "HCL">HCL</option>
           <option value = "None1">None</option>
    </select></div></div>

然后我在表格中使用此代码

 <input type="button" id="add_Analyte" onclick="add_Analyte" value="ADD ANALYTE" /></div>
<script>
$(document).ready(function() {
var _counter = 0;
function add_Analyte() {
_counter++;
var newFields = document.getElementById("Analyte").cloneNode(true);
newFields.id = "";
newFields.style.display = "block";
var newField = newFields.childNodes;
for (var i=0;i<newField.length;i++) {
var theName = newField[i].name
    if (theName)
        newField[i].name = theName + counter;
}
var insertHere = document.getElementById("addAnalyte");
insertHere.parentNode.insertBefore(newFields,insertHere);
}
})
</script> 
4

0 回答 0