<input type="radio" class="input2" name="business_role" id="business_role" value="seller" onclick="tr_display('sell');"> 销售 <input type="radio" class="input2" name="business_role" value="buyer" onclick="tr_display('buy');"> 采购<SCRIPT LANGUAGE="JavaScript">
<!--
function tr_display(strValue){
if(document.all["business_role"][0].checked==true){
alert("first radio is checked");
}else{
alert("second radio is checked");
}
alert(strValue);
}
//business_role.checked  = true; 什么意思?
//-->
</SCRIPT>

解决方案 »

  1.   

    document.all.business_role.checked  = true;
      

  2.   

    document.all.business_role
    business_role
    这些取得的是一组控件,而不是一个控件,你怎么给他们设置 checked 属性??
      

  3.   

    每个 radio 设一个不同的 id 然后用 id 来访问就行了: <input type="radio" name="business_role" id="a1" value="seller" onclick="tr_display('sell');"> 
    销售 
    <input type="radio" name="business_role" id="a2" value="buyer" onclick="tr_display('buy');"> 
    采购
    <script language="JavaScript">
    a1.checked=true;
    </script>
      

  4.   

    为什么非要用脚本来选中呢?在<input>里加上 checked="true" 不就可以了吗