有没有说,当我选中select中某个值的时间,现在也选中指定的checkbox?本人是Javascript的新手,不是很懂,请各位多多指教!
------解决方案--------------------
<select onchange= "mmm(this.value) ">
<option value= "11 "> 1111 </option>
<option value= "22 "> 2222 </option>
</select>
<input type= "checkbox " value= "4 " name = "btn4 " id= "btn4 ">
<input type= "checkbox " value= "5 " name = "btn5 " id= "btn5 ">
function mmm(a){
if(a==11){
document.getElementById( "btn4 ").checked=true
document.getElementById( "btn5 ").checked=false
}
if(a==22){
document.getElementById( "btn5 ").checked=true
document.getElementById( "btn4 ").checked=false
}
}
------解决方案--------------------
我试过的,可以的 你是不是没加 <script> </script>
<select onchange= "mmm(this.value) ">
<option value= "11 "> 1111 </option>
<option value= "22 "> 2222 </option>
</select>
<input type= "checkbox " value= "4 " name = "btn4 " id= "btn4 ">
<input type= "checkbox " value= "5 " name = "btn5 " id= "btn5 ">
<script>
function mmm(a){
if(a==11){
document.getElementById( "btn4 ").checked=true
document.getElementById( "btn5 ").checked=false
}
if(a==22){
document.getElementById( "btn5 ").checked=true
document.getElementById( "btn4 ").checked=false
}
}
</script>