我正在合并我在此站点上找到的代码,用于创建动态表单,可在此处找到。
但是,我遇到了一个问题,我只能在 div 中添加这么多行,然后才会导致页面上出现错误。有什么办法可以补救这种情况吗?这是我要生成的整个 div:
Server Name: <input type=”text” name=”ServerName”><br>
Operating System: <input type=”text” name=”OperatingSystem”><br>
Hardware: <input type=”text” name=”Hardware”><br>
Up Time: <input type=”text” name=”UpTime” size="1" maxlength="3"> day(s)<br>
<p>
HP System Management/Dell OpenManage/IBM: <input type=”text” name=”HPSystemManagementDellOpenManageIBM”><br>
<p>
Anti-Virus Software: <input type=”text” name=”Anti-VirusSoftware”><br>
- Info Correct: <input type=”text” name=”InfoCorrect”><br>
- Definitions: <input type=”text” name=”Definitions”><br>
- Updates: <input type=”text” name=”Updates”><br>
- TM Agents: <input type=”text” name=”TMAgents”><br>
- TM Scan: <input type=”text” name=”TMScan”><br>
- TM License: <input type=”text” name=”TMLicense”><br>
- TM Version: <input type=”text” name=”TMVersion”><br>
<p>
Backup Software: <input type=”text” name=”BackupSoftware”><br>
- Info Correct: <input type=”text” name=”InfoCorrect”><br>
- Backups: <input type=”text” name=”Backups”><br>
- Updates: <input type=”text” name=”Updates”><br>
<p>
Exchange: <input type=”text” name=”Exchange”><br>
- Database Mounted: <input type=”text” name=”DatabaseMounted”><br>
- Exchange Services running: <input type=”text” name=”ExchangeServicesrunning”><br>
<p>
Event Log: <input type=”text” name=”EventLog”><br>
<p>
Updates: <input type=”text” name=”Updates”><br>
<p>
--------------------------------------------------
<p>
我正在合并的代码如下:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#btnAdd').click(function() {
var num = $('.clonedInput').length;
var newNum = new Number(num + 1);
var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
newElem.children(':first').attr('id', 'name' + newNum).attr('name', 'name' + newNum);
$('#input' + num).after(newElem);
$('#btnDel').attr('disabled','');
if (newNum == 5)
$('#btnAdd').attr('disabled','disabled');
});
$('#btnDel').click(function() {
var num = $('.clonedInput').length;
$('#input' + num).remove();
$('#btnAdd').attr('disabled','');
if (num-1 == 1)
$('#btnDel').attr('disabled','disabled');
});
$('#btnDel').attr('disabled','disabled');
});
</script>
我会很感激任何帮助。
编辑:
此外,我希望能够让这个 div 成为默认隐藏的可选附加组件。它不需要重复。
<div id="OMMaintenance">
OM Maintenance Notes: <input type=”text” name=”OMMaintenanceNotes”><br>
Up Time: <input type=”text” name=”OMUpTime” size="1" maxlength="3"> day(s)<br>
Event Log: <input type=”text” name=”OMEventLog”><br>
Updates: <input type=”text” name=”OMUpdates”><br>
</div>
再次,谢谢。