在我的代码中,我有一个用户填写的HTML表单。然后他们在字段中输入一个值"成员"然后单击按钮以生成div =' sector_prop'的其他副本。 表格部分是 - 部门数量(LTE)
<br>
<br>
<input type="text" id="member" name="member" value="">
<br>
<br>
<button>Generate Sector Properties</button>
这里div&#34; sector_prop&#34;是
<div class="sector_prop">
<fieldset>
Primary LTE Carrier (Select lowest frequency on the site 850 for Band 5, AWS
for Band 4 and PCS for Band 2)<br>
<br>
<select name="lte_freq1">
<option value="6">850</option>
<option value="2">AWS</option>
<option value="4">PCS</option>
</select>
<br>
</fieldset>
我想使用for循环追加div。此代码非常适用于值1,2,3,4,5。当number的值为6或更高时,代码中断并附加超过所需的div。我试图找出为什么会发生这种情况。有什么建议吗?
$(document).ready(function(){
$("button").click(function(){
var number = document.getElementById("member").value;
var repeat = $('.sector_prop');
var cloned = repeat.clone(true);
console.log(number);
for (i=1;i<number;i++){
cloned.appendTo('.sector_prop');
console.log(i);
console.log(cloned);
}
});
});
$(document).ready(function(){
$("button").click(function(){
var number = document.getElementById("member").value;
var repeat = $('.sector_prop');
var cloned = repeat.clone(true);
console.log(number);
for (i=1;i<number;i++){
cloned.appendTo('.sector_prop');
console.log(i);
console.log(cloned);
}
});
});
&#13;
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<form action="/form" method="post">
<fieldset>
<legend><b> Transport Information</b></legend>
<br>
<br>
OAM IP:<br>
<input type="text" name="oam_ip" pattern="^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$" required>
<br>
<br>
<fieldset>
<fieldset>
<legend><b> RF Parameters</b></legend>
<br>
Number of Sectors (LTE)<br>
<br>
<input type="text" id="member" name="member" value="">
<br>
<br>
<button>Generate Sector Properties</button>
<br>
<br>
<fieldset>
<div class="sector_prop">
<fieldset>
Primary LTE Carrier (Select lowest frequency on the site 850 for Band 5, AWS for Band 4 and PCS for Band 2)<br>
<br>
<select name="lte_freq1">
<option value="6">850</option>
<option value="2">AWS</option>
<option value="4">PCS</option>
</select>
<br>
<br>
</fieldset>
</div>
<input type="submit">
</form>
<br>
<br>
</body>
&#13;
答案 0 :(得分:0)
这看起来像你在说什么吗?
Sub CopyPaste()
Dim CitiReportEUR As Workbook
Dim CitiReportPathEUR As String
CitiReportPathEUR = Range("CitiReportPathEUR")
Set CitiReportEUR = Workbooks.Open(Filename:=CitiReportPathEUR)
With CitiReportEUR.Sheets(1)
LastRowCiti = .Range("I" & .Rows.Count).End(xlUp).Row
Set RngCitiEUR = .Range("A1:CT" & LastRowCiti).SpecialCells(xlCellTypeVisible)
End With
CabReport.Sheets("CITI").Range("C1").Resize(RngCitiEUR.Rows.Count, RngCitiEUR.Columns.Count).Value = RngCitiEUR.Value
End Sub
&#13;
$(document).ready(function(){
$("button").click(function(){
var number = document.getElementById("member").value;
var repeat = $('fieldset');
var cloned;
//console.log(number);
for (i=1;i<number;i++){
cloned = repeat.clone(true);
cloned.appendTo('.sector_prop');
//console.log(i);
//console.log(cloned);
}
});
});
&#13;