close
這也是時常會用到的一種手段 相當適合大表格 (因為回傳到 server side 要花很久)
當然 也是有缺點的 須一次把所有可能的內容全部塞到client side (javascript可沒法無中生有)
<script language="javascript">
function sel_onchange() {
switch( sel_test.value ) {
case "1": show.value = "this is 1"; break;
case "2": show.value = "this is 2"; break;
case "3": show.value = "this is 3"; break;
default: show.value = "unknow choice"; // it should never be seen
}
if( aRadio.checked ) {
theCheckboxA.checked = true;
theCheckboxB.checked = false;
}
else {
theCheckboxA.checked = false;
theCheckboxB.checked = true;
}
}
</script>
當然 也是有缺點的 須一次把所有可能的內容全部塞到client side (javascript可沒法無中生有)
<script language="javascript">
function sel_onchange() {
switch( sel_test.value ) {
case "1": show.value = "this is 1"; break;
case "2": show.value = "this is 2"; break;
case "3": show.value = "this is 3"; break;
default: show.value = "unknow choice"; // it should never be seen
}
if( aRadio.checked ) {
theCheckboxA.checked = true;
theCheckboxB.checked = false;
}
else {
theCheckboxA.checked = false;
theCheckboxB.checked = true;
}
}
</script>
<body onLoad="sel_onchange()">
<select name="sel_test" onchange="sel_onchange()">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
</select>
<input type="text" name="show">
<br>
Check it if want the checkboxA be checked <input type="radio" name="aRadio" onClick="sel_onchange()"><br>
<input type="checkbox" name="theCheckboxA"> checkboxA, and<br>
<input type="checkbox" name="theCheckboxB"> if checkboxA is not checked
</body>
<select name="sel_test" onchange="sel_onchange()">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
</select>
<input type="text" name="show">
<br>
Check it if want the checkboxA be checked <input type="radio" name="aRadio" onClick="sel_onchange()"><br>
<input type="checkbox" name="theCheckboxA"> checkboxA, and<br>
<input type="checkbox" name="theCheckboxB"> if checkboxA is not checked
</body>
全站熱搜
留言列表