gpt4 book ai didi

php - 下拉隐藏值

转载 作者:行者123 更新时间:2023-11-28 13:45:19 26 4
gpt4 key购买 nike

我希望仅当用户选择月份而不是空白值时才显示 1 的日期值,但它不起作用...我认为该功能有误。我希望只有在没有选择月份的情况下,日期下拉列表中的 1 才会显示无。请帮助我....

<html>
<head>
<script type="text/javascript">
function show(x) {
var mon = document.getElementById(x).innerHTML
if (mon == "") {
document.getElementById("one").style.display="none";
} else {
document.getElementById("one").style.display="";
}
}
</script>

</head>

<body>
Calendar<br>
<hr align="left" width="200px"/>


--Year ------ Month ----- Day<br>
<select name="year">
<option value="defaulty"></option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>

<select name="month" onchange="show(this)">
<option id="defaultm"></option>
<option id="January">January</option>
<option id="February">February</option>
<option id="March">March</option>
<option id="April">April</option>
<option id="May">May</option>
<option id="June">June</option>
<option id="July">July</option>
<option id="August">August</option>
<option id="September">September</option>
<option id="October">October</option>
<option id="November">November</option>
<option id="December">December</option>
</select>

<select name="day">
<option id="defaultd" value="defaultd"></option>
<option id="one" value="one" style="display:none">1</option>

</select>

</body>

</html>

最佳答案

所以您希望只有在选择了正确的月份后才能使用日期列?如果我对您的理解正确的话,这就可以解决问题。

<html>
<head>
<script type="text/javascript">

function show() {

if (document.getElementById("month").selectedIndex != 0) {
document.getElementById("day").disabled = false;
}
else {
document.getElementById("day").disabled = true;
}
}
</script>
</head>
<body>

Calendar<br>
<hr align="left" width="200px"/>
<form actn="">
--Year ------ Month ----- Day<br>
<select name="year" id="year">
<option value="defaulty"></option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>
<select name="month" id="month" onchange="show()">
<option value="defaultm"></option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<select name="day" id="day" disabled="disabled">
<option id="defaultd" value="defaultd"></option>
<option id="one" value="one">1</option>
</select>
</form>
</body>

关于php - 下拉隐藏值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11941065/

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