我无法让 jquery 代码按我的需要工作,所以我使用 php 循环将选择写入我的 html 以填充它们,如下所示:
<td id="selmn_td"><label>Times: </label>
<select name="selectMN" id="selectorMN" ><?PHP
for ($i = 1;$i<13;$i++)
echo "<option value=" . $i . ">" .$i . "</option>";
?>
</select></td>
</tr>
<tr>
<td id="selwk_td"><label>Times: </label>
<select name="selectWK" id="selector" style="visibility:hidden" ><?PHP
for ($i = 1;$i<53;$i++)
echo "<option value=" . $i . ">" .$i . "</option>";
?>
</select><label id="weeks"></label><label id="months"></label></td>
<td> </td>
<td> </td>
<td id="weekdays" colspan="2">
<input type="checkbox" name="weekdays[]" value="Monday" id="weekdays_0" />Mon</label><label>
<input type="checkbox" name="weekdays[]" value="Tuesday" id="weekdays_1" />Tues</label><label>
<input type="checkbox" name="weekdays[]" value="Wednesday" id="weekdays_2" />Wed</label><label>
<input type="checkbox" name="weekdays[]" value="Thursday" id="weekdays_3" />Thu</label><label>
<input type="checkbox" name="weekdays[]" value="Friday" id="weekdays_4" />Fri</label><label>
<input type="checkbox" name="weekdays[]" value="Saturday" id="weekdays_5" />Sat</label><label>
<input type="checkbox" name="weekdays[]" value="Sunday" id="weekdays_6" />Sun</label>
</td>
然后我使用以下 jquery 来显示和隐藏输入字段:
$('#RadioGroup1_0').change(function()
{
document.getElementById('radio_duration_td').style.visibility="visible";
document.getElementById('selwk_td').style.visibility="visible";
document.getElementById('selector').style.visibility="visible";
document.getElementById('weekdays').style.visibility="visible";
$('#RadioGroup1_1').change(function()
{
document.getElementById('radio_duration_td').style.visibility="hidden";
document.getElementById('selwk_td').style.visibility="hidden";
document.getElementById('selector').style.visibility="hidden";
document.getElementById('weekdays').style.visibility="hidden";
document.getElementById('selmn_td').style.visibility="hidden";
}
);
$('#radio_duration_1').change(function()
{
document.getElementById('weeks').style.visibility="hidden";
document.getElementById('weekdays').style.visibility="hidden";
document.getElementById('selmn_td').style.visibility="visible";
document.getElementById('selector').style.visibility="hidden";
document.getElementById('selwk_td').style.visibility="hidden";
//document.getElementById('selwk_td').style.visibility="visible";
//document.getElementById('selector').style.visibility="visible";
}
);
$('#radio_duration_2').change(function()
{
document.getElementById('weekdays').style.visibility="visible";
document.getElementById('selector').style.visibility="visible";
document.getElementById('selwk_td').style.visibility="visible";
document.getElementById('selmn_td').style.visibility="hidden";
//document.getElementById('months').style.visibility="hidden";
}
这并不理想,但是当最后期限被推迟时,您必须选择可行的方法。对此的建议仍将不胜感激!