想知道如何修复这个 js 以使其正常工作。我正在隐藏一个部分以显示另一个部分,并且如果“关闭?”,我还会禁用小时文本框。复选框被选中。隐藏/显示/禁用部分有效,但时间选择器不起作用。在尝试添加编码的日期选择器部分之前,我试图弄清楚为什么它不起作用......
无论如何,这是我所指部分的代码......
<link rel="stylesheet" type="text/css" href="includes/css/adm.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.0/jquery-ui.min.js"></script>
<script type="text/javascript" src="includes/js/timepicker.js"></script>
<script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
<script>
$("#tstart").timepicker({
timeFormat: "hh:mm tt",
stepMinute: 15,
minuteGrid: 15,
hourMin: 6,
hourMax: 16
});
</script>
<script>
$("#tend").timepicker({
timeFormat: "hh:mm tt",
stepMinute: 15,
minuteGrid: 15,
hourMin: 11,
hourMax: 23
});
</script>
<script type="text/javascript">
function fields(){
if (document.getElementById('working').checked == 1){
document.getElementById('tstart').disabled='disabled';
document.getElementById('tend').disabled='disabled';
document.getElementById('type').style.display = 'none';
document.getElementById('type').style.visibility = 'hidden';
document.getElementById('off').style.display = 'inline';
document.getElementById('off').style.visibility = 'visible';
}else{
document.getElementById('tstart').disabled='';
document.getElementById('tend').disabled='';
document.getElementById('type').style.display = 'inline';
document.getElementById('type').style.visibility = 'visible';
document.getElementById('off').style.display = 'none';
document.getElementById('off').style.visibility = 'hidden';
}
}
</script>
<td class="add_hours_left_top">Date: </td>
<td class="add_hours_right_top">
<input type="text" name="date" id="date" size="22" value="">
<input type="hidden" name="work" value="0">
<input type="checkbox" title="Check if off work!" name="work" id="working" value="1" onclick="fields();" />Off?
</td>
</tr>
<tr>
<td class="add_hours_left">Hours: </td>
<td class="add_hours_right">
<input type="text" name="timestart" id="tstart" size="10" value=""> to
<input type="text" name="timeend" id="tend" size="10" value="">
</td>
</tr>
<tr>
<td class="add_hours_reason_select" colspan="2" id="type">
<div class="add_hours_type_name">Type of work to be done:</div>
<input type="hidden" name="work_type" value="0" checked />
Temps <input type="radio" name="work_type" value="1" /><b>·</b>
Scrub Floors <input type="radio" name="work_type" value="2"/></br>
Leave Early or Later <input type="radio" name="work_type" value="3"/><b>·</b>
Training <input type="radio" name="work_type" value="4"/></br>
</label>
</td>
</tr>
<tr>
<td class="add_hours_reason_select" colspan="2" id="off" style="display:none;">
<div class="add_hours_type_name">Reason off work:</div>
<input type="hidden" name="why_off" value="0" checked />
Request <input type="radio" name="why_off" value="1" /><b>·</b>
Medical Leave <input type="radio" name="why_off" value="2"/></br>
</label>
</td>
谢谢您的帮助!