我正在整合我在此网站上找到的代码,用于创建动态表单,找到here。
但是,我遇到了一个问题,我只能在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>
再次,谢谢。