单选框 复选框 问题。
<input type= "radio " name= "SF_VALID_TYPE " value= "all " >
<input type= "radio " name= "SF_VALID_TYPE " value= "part " >
<input type= "checkbox " name= "SF_VALID_CPCODE " value= "1 " >
<input type= "checkbox " name= "SF_VALID_CPCODE " value= "2 " >
<input type= "checkbox " name= "SF_VALID_CPCODE " value= "3 " >
当选择单选框是“part”的时候,如果复选框没有选择,就alert( "test ");
如何写脚本。谢谢
------解决方案-------------------- <script type= "text/javascript ">
function test(obj)
{
if(obj.checked)
{
objCB = document.getElementsByName( "SF_VALID_CPCODE ");
for (var i = 0; i < objCB.length; i++)
{
if (objCB[i].checked) return;
}
alert( "test ");
}
}
</script>
<input type= "radio " name= "SF_VALID_TYPE " value= "all " >
<input type= "radio " name= "SF_VALID_TYPE " value= "part " onClick= "javascript:test(this); " >
<input type= "checkbox " name= "SF_VALID_CPCODE " value= "1 " >
<input type= "checkbox " name= "SF_VALID_CPCODE " value= "2 " >
<input type= "checkbox " name= "SF_VALID_CPCODE " value= "3 " >