我的代码是一团糟,很抱歉。禁用多选与复选框
该JS的作品,但只为第一选择;我希望用户输入时间,但如果用户当天不工作,我想禁用这四个选择框。不幸的是,我不知道在JS中添加其他选择。
还有另一个脚本填充选择的其余选项。 代码我到目前为止有:
if (document.getElementById('holiday_check').checked)
document.getElementById('holiday_time_h1').setAttribute('disabled', 'disabled');
function closed_holiday() {
if (document.getElementById('holiday_check').checked)
document.getElementById('holiday_time_h1').setAttribute('disabled', 'disabled');
else
document.getElementById('holiday_time_h1').removeAttribute('disabled');
}
<div>
\t <span>Opening Time:</span>
\t <select id="holiday_time_h1"><option>00</option></select>
\t :
\t <select id="holiday_time_m1"><option>00</option></select>
\t \t
\t <span>Closing time</span>
\t <select id="holiday_time_h2"><option>00</option></select>
\t :
\t <select id="holiday_time_m2"><option>00</option></select>
\t \t
<input id="holiday_check" class="check" type="checkbox" onchange="closed_holiday();">Closed</input>
\t \t \t \t \t
</div>
关闭点击你想禁用所有的选择框? – Dhara
是的,但只有4提到selectboxes,因为有3个其他工作相同的div –
你可以像'文档一样做吗?getElementsByTagName('select')。setAttribute('disabled','disabled');'?隐藏所有的框? – Dhara