0

我正在合并我在此站点上找到的代码,用于创建动态表单,可在此处找到。

但是,我遇到了一个问题,我只能在 div 中添加这么多行,然后才会导致页面上出现错误。有什么办法可以补救这种情况吗?这是我要生成的整个 div:

Server Name: <input type=”text” name=”ServerName”&gt;<br>
Operating System: <input type=”text” name=”OperatingSystem”&gt;<br>
Hardware: <input type=”text” name=”Hardware”&gt;<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”&gt;<br>
<p>
Anti-Virus Software: <input type=”text” name=”Anti-VirusSoftware”&gt;<br>
 - Info Correct: <input type=”text” name=”InfoCorrect”&gt;<br>
 - Definitions: <input type=”text” name=”Definitions”&gt;<br>
 - Updates: <input type=”text” name=”Updates”&gt;<br>
 - TM Agents: <input type=”text” name=”TMAgents”&gt;<br>
 - TM Scan: <input type=”text” name=”TMScan”&gt;<br>
 - TM License: <input type=”text” name=”TMLicense”&gt;<br>
 - TM Version: <input type=”text” name=”TMVersion”&gt;<br>
<p>
Backup Software: <input type=”text” name=”BackupSoftware”&gt;<br>
 - Info Correct: <input type=”text” name=”InfoCorrect”&gt;<br>
 - Backups: <input type=”text” name=”Backups”&gt;<br>
 - Updates: <input type=”text” name=”Updates”&gt;<br>
<p>
Exchange: <input type=”text” name=”Exchange”&gt;<br>
 - Database Mounted: <input type=”text” name=”DatabaseMounted”&gt;<br>
 - Exchange Services running: <input type=”text” name=”ExchangeServicesrunning”&gt;<br>
<p>
Event Log: <input type=”text” name=”EventLog”&gt;<br>
<p>
Updates: <input type=”text” name=”Updates”&gt;<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”&gt;<br>
Up Time: <input type=”text” name=”OMUpTime” size="1" maxlength="3"> day(s)<br>
Event Log: <input type=”text” name=”OMEventLog”&gt;<br>
Updates: <input type=”text” name=”OMUpdates”&gt;<br>
</div>

再次,谢谢。

4

0 回答 0