Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以使用纯JavaScript根据下拉选择的值在下面的html中重复该模板吗?_Javascript_Html - Fatal编程技术网

我可以使用纯JavaScript根据下拉选择的值在下面的html中重复该模板吗?

我可以使用纯JavaScript根据下拉选择的值在下面的html中重复该模板吗?,javascript,html,Javascript,Html,我有一个html页面。我面临的问题是,我无法提出一种基于下拉值“Chasis数”显示多个模板的方法。例如,如果我从下拉列表中选择“Chasis的数量”为2,我希望模板显示两次,并且水平显示,而不是垂直显示。有没有办法做到这一点?非常感谢您的帮助。谢谢 <fieldset id='extra'> <h6>Additional Details Required for Controller A</h6>

我有一个html页面。我面临的问题是,我无法提出一种基于下拉值“Chasis数”显示多个模板的方法。例如,如果我从下拉列表中选择“Chasis的数量”为2,我希望模板显示两次,并且水平显示,而不是垂直显示。有没有办法做到这一点?非常感谢您的帮助。谢谢

            <fieldset id='extra'>
                <h6>Additional Details Required for Controller A</h6>
                <label for='Controller_ID1'>Controller_ID:</label>
                    <select name='Controller_ID1' required>
                    <option value=""> - Select the Controller ID - </option>
                    <option value='A'>A </select>
                <label for='iSCSI1'>iSCSI IPs:</label><input type='text' name='iSCSIip1' id="ip1" placeholder='Enter iSCSI ips'  disabled="disabled" />
                <label for='HBA_Ports_A'>HBA_Ports:</label><input type='text' id="hba" name='hba_ports1'  placeholder='Enter the HBA Ports' disabled="disabled" />
                <label for='MC_IP_A'>MC_IP:</label><input type='text' name='extra_ip1' placeholder='Enter the MC_IP' /> 
                <label for='MC_Netmask_A'>MC_Netmask:</label><input type='text' name='netmask_ip1' placeholder='Enter the MC_Netmask' /> 
                <label for='MC_Gateway_A'>MC_Gateway:</label><input type='text' name='gateway_ip1' placeholder='Enter the MC_Gateway' /> 
                <label for='MC_A'>MC:</label><input type='text' name='rbod_mc1' placeholder='Enter the MC Port' onkeypress="return (event.charCode > 64 && 
                event.charCode < 91) || (event.charCode > 96 && event.charCode < 123)" /> 
                <label for='SC_A'>SC:</label><input type='text' name='rbod_sc1' placeholder='Enter the SC Port' onkeypress="return (event.charCode > 64 && 
                event.charCode < 91) || (event.charCode > 96 && event.charCode < 123)" /> 
                <label for='FU_A'>FU:</label><input type='text' name='rbod_fu1' placeholder='Enter the FU Port' onkeypress="return (event.charCode > 64 && 
                event.charCode < 91) || (event.charCode > 96 && event.charCode < 123)"/> 
                <label for='EC_A'>EC:</label><input type='text' name='rbod_ec1' placeholder='Enter the EC Port' onkeypress="return (event.charCode > 64 && 
                event.charCode < 91) || (event.charCode > 96 && event.charCode < 123)" /> 
<br>
<br>
                <h6>Additional Details Required for Controller B</h6>
                <label for='Controller_ID'>Controller_ID:</label>
                    <select name='Controller_ID' id="ctlid" required>
                    <option value=""> - Select the Controller ID - </option>
                    <option value='B'>B </select>
                <label for='iSCSI2'>iSCSI IPs:</label><input type='text' name='iSCSIip2' id="ip2" placeholder='Enter iSCSI ips' disabled="disabled" />
                <label for='HBA_Ports'>HBA_Ports:</label><input type='text' id="hba1" name='hba_ports' placeholder='Enter the HBA Ports' disabled="disabled" />
                <label for='MC_IP'>MC_IP:</label><input type='text' name='extra_ip' id='mcip' placeholder='Enter the MC_IP'  /> 
                <label for='MC_Netmask'>MC_Netmask:</label><input type='text' name='netmask_ip' id="netmaskip" placeholder='Enter the MC_Netmask' /> 
                <label for='MC_Gateway'>MC_Gateway:</label><input type='text' name='gateway_ip' id="gatewayip" placeholder='Enter the MC_Gateway'  /> 
                <label for='MC'>MC:</label><input type='text' name='rbod_mc' placeholder='Enter the MC Port' id="rbodmc"onkeypress="return (event.charCode > 64 && 
                event.charCode < 91) || (event.charCode > 96 && event.charCode < 123)" /> 
                <label for='SC'>SC:</label><input type='text' name='rbod_sc' placeholder='Enter the SC Port' id="rbodsc" onkeypress="return (event.charCode > 64 && 
                event.charCode < 91) || (event.charCode > 96 && event.charCode < 123)" /> 
                <label for='FU'>FU:</label><input type='text' name='rbod_fu' placeholder='Enter the FU Port' id="rbodfu" onkeypress="return (event.charCode > 64 && 
                event.charCode < 91) || (event.charCode > 96 && event.charCode < 123)" /> 
                <label for='EC'>EC:</label><input type='text' name='rbod_ec' placeholder='Enter the EC Port' id="rbodec" onkeypress="return (event.charCode > 64 && 
                event.charCode < 91) || (event.charCode > 96 && event.charCode < 123)" /> 

            </fieldset>
        </template> 

    <fieldset>
                <label for='Chasis Input'><strong>Number of Chasis</strong></label>
                <select input type='text' name='chassis'   required >
                <option value=""> - Number of Controllers - </option>
                <option data-extra=true value='1'>1
                <option data-extra=true value='2'>2
                </select>
            </fieldset> ```

您的下拉选择可以更改元素的css显示属性,以便您可以显示:隐藏您不想显示的内容。对于您的水平目标也是如此,请查看css网格:

另外,我建议使用litelement,这是一个用于创建/操作和处理模板的强大且易于使用的库

函数remove\u all\u dom{ Array.prototype.forEach.calldocument.querySelectorAll.chasie.functiondom{ document.body.removechildom } } 函数的变化{ 删除所有对象 var value=dom.value 对于变量i=1;i谢谢你的回复。我正在寻找一个js函数,通过它我可以根据用户输入多次显示模板