有三个checkbox
1,消费金额
2,取现金额
3,账单余额
要求:
(1)、1选中,2可选,3变灰
(2)、2选中,1可选,3变灰
(3)、3选中,1变灰,2变灰
(4)、录入输入框中
代码如下:
<html> <head> <title>选中复选框</title> <script language=Javascript> var tem = ""; function checkAll(e,itemName,thisvalue) { var obj = e; var container1 = document.getElementById("BuyMoney1"); var container2 = document.getElementById("GetMoney"); var container3 = document.getElementById("FormMoney"); container1.disabled=container3.checked; container2.disabled=container3.checked; container3.disabled=!(!container1.checked && !container2.checked); tem= document.getElementById("inputid").value; var aa=document.getElementsByName(itemName); var bb=document.getElementById('inputid'); if(e.checked==true){ tem += thisvalue+","; } else{ tem = tem.replace(thisvalue+",",""); } bb.value=tem; for (var i=0; i<aa.length; i++) aa[i].checked = e.checked; } </script> </head> <body> <input type="checkbox" id="BuyMoney1" name="checkbox" size="50%" value='消费金额' />消费金额 <input type="checkbox" id="GetMoney" name="checkbox" size="50%" value='取现金额' type="checkbox" id="FormMoney" name="checkbox" size="50%" value='账单余额' type="text" name="input" size='30' id="inputid"/> </body></html>
希望对大家有帮助!!!