gpt4 book ai didi

html - 添加一个 js,如果选择下拉菜单,请说 yeseg2 添加第三个新的第 4 个复选框

转载 作者:行者123 更新时间:2023-11-28 02:19:31 25 4
gpt4 key购买 nike

我希望在页面加载后可以通过某种方式编写 js 代码,如果选择了一个下拉菜单,比如 yeseg2 它只向现有的 3 个复选框添加一个新的复选框,如显示:无,如果有人可以帮助它很棒

<html>
<head>
</head>
<body>

<select id='ecerxi' name="ecerx" size=1>
<option value="yes1">yeseg1</option>
<option value="yes2">yeseg2</option>
<option value="yes3">yeseg3</option>
</select>

<br>
<br>
<input type="checkbox" name="tb1" value="yes1c" >yes check box 1
<br>
<input type="checkbox" name="tb2" value="yes2c" >yes check box 2
<br>
<input type="checkbox" name="tb3" value="yes3c" >yes check box 3
<br>


</body>

最佳答案

 <body>
<div>
<select onChange="Function1(this.options[this.selectedIndex].value)">
<option value="yes1">yeseg1</option>
<option value="yes2">yeseg2</option>
<option value="yes3">yeseg3</option>
</select>
</div>

<p>Test Paragraph</p>
<input type="checkbox" name="tb1" value="yes">yes check box 1
<br>
<input type="checkbox" name="tb2" value="yes">yes check box 2
<br>
<input type="checkbox" name="tb3" value="yes">yes check box 3
<br>



<div id="Set_2_cb">

</div>

<script>
function Function1(selinfo) {
console.log(selinfo);
if (selinfo == 'yes2') {
document.getElementById('Set_2_cb').innerHTML = '<input type="checkbox" name="tb4" value="yes">check box 4';
} else {
document.getElementById('Set_2_cb').innerHTML = ' ';
}
}
</script>
</body>

关于html - 添加一个 js,如果选择下拉菜单,请说 yeseg2 添加第三个新的第 4 个复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58704358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com