单选按钮控制两个表单是否生效的代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>单选按钮控制两个表单是否生效的代码 - www.webdm.cn</title>
</head>
<body>
<table id="mytable">
<tr height="25">
<td colspan="2" bgcolor="#E5E5E5"style="font-weight: bold;color: #00008B;border: 1px solid gray;">客户</td>
</tr>
<tr>
<td width="563"style="border-bottom: 1px solid gray;border-left: 1px solid gray;border-right: 1px solid gray;">
<table width="100%">
<tr height="25" bgcolor="#F5F5F5">
<td align="center" nowrap="nowrap"><input type="radio" name="cumkind" value="1"checked="checked"/>
<span style="font-weight: bold;">单位委托</span>
<span style="color: red;">*</span>
<span id="c1">单位名称</span>
<input type="text" id="companyName" name="companyName" style="width: 180px;" /></td>
</tr>
<tr>
<td>
<div style="margin-left: 11px;">
<span id="c2">注册资金</span>
<input type="text" id="regMoney" name="regMoney" style="width: 89px;" />
<span id="c4">联 系 人</span>
<input type="text" style="width: 89px;" id="comname" name="touch2" />
</div></td>
</tr>
</table>
</td>
<td width="400" style="border-bottom: 1px solid gray;border-right: 1px solid gray;">
<table width="100%">
<tr height="25" bgcolor="#F5F5F5">
<td>
<div style="float: left;width: 100px;" align="center">
<input type="radio" name="cumkind" value="2"/>
<span style="font-weight: bold;">个人委托</span></div>
<div style="margin-left: 118px;">
<span style="color: red;">*</span>
<span id="p1">姓名</span>
<input type="text" id="name" name="touch" style="width: 73px;"/>
</div></td>
</tr>
<tr>
<td nowrap="nowrap"><div style="margin-left: 124px;"><span id="p3">年龄</span>
<input type="text" id="age" name="age" style="width: 73px;"/>
</div></td>
</tr>
</table>
</td>
</tr>
</table>
<script>
var obj,ok;
var objarray=[]
function init(){
obj=document.getElementsByName("cumkind"),ok=obj.length;
for (var i=0;i<ok;i++){
obj[i].index=i
getparent(obj[i])
obj[i].οnclick=function(){changme(this)}
}
obj[0].click()
}
function changme(o){
for (var i=0;i<ok;i++){
if (i==o.index){
disabl(i,false);
document.getElementById(objarray[i]).style.color="#000";
document.getElementById(objarray[i]).getElementsByTagName("span")[1].style.color="#f00";}
else {
disabl(i,true);
document.getElementById(objarray[i]).style.color="#aaa";
document.getElementById(objarray[i]).getElementsByTagName("span")[1].style.color="#aaa";}
obj[i].disabled=false
}
}
function disabl(n,tf){
if (document.getElementById(objarray[n]).getElementsByTagName("input").length>0){
var obj_input=document.getElementById(objarray[n]).getElementsByTagName("input")
for (var j=0;j<obj_input.length;j++)obj_input[j].disabled=tf
}
if (document.getElementById(objarray[n]).getElementsByTagName("select").length>0){
var obj_select=document.getElementById(objarray[n]).getElementsByTagName("select")
for (var j=0;j<obj_select.length;j++) obj_select[j].disabled=tf
}
}
function getparent(o){//获取"cumkind"所在<table>对象id
var pn=o.parentNode
if (pn.tagName.toLowerCase()=="td"){
pn=pn.parentNode.parentNode.parentNode;
objarray[objarray.length]=pn.id="t"+objarray.length
}
else getparent(pn)
}
οnlοad=init
</script>
</body>
</html>

<a href="http://www.webdm.cn">网页代码站</a> - 最专业的代码下载网站 - 致力为中国站长提供有质量的代码!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值