修改了一下。<html>
<head>
<title> 无标题页 </title>
<script language="javascript">
function change(a,b,c)
{
var chk1=document.getElementById(a);
var txt1=document.getElementById(b);
var txt2=document.getElementById(c);
txt1.disabled=true;
if(chk1.checked){
txt2.disabled=false;
txt2.value=txt1.value;
} else{
txt2.value="";
chk1.checked=false;
}
}
</script>
</head>
<body >
<table>
<tr>
<td>
<input type="checkbox" id="chk" onclick="change( 'chk', 'm1', 'm2')" />
</td>
<td>
<input type="text " id= "m1" value= "haha" disabled="true"/>
<input type="text " id= "m2" disabled="true" />
</td>
</tr>
</table>
</body>
</html>
<head>
<title> 无标题页 </title>
<script language="javascript">
function change(a,b,c)
{
var chk1=document.getElementById(a);
var txt1=document.getElementById(b);
var txt2=document.getElementById(c);
txt1.disabled=true;
if(chk1.checked){
txt2.disabled=false;
txt2.value=txt1.value;
} else{
txt2.value="";
chk1.checked=false;
}
}
</script>
</head>
<body >
<table>
<tr>
<td>
<input type="checkbox" id="chk" onclick="change( 'chk', 'm1', 'm2')" />
</td>
<td>
<input type="text " id= "m1" value= "haha" disabled="true"/>
<input type="text " id= "m2" disabled="true" />
</td>
</tr>
</table>
</body>
</html>
解决方案 »
- google map api 密钥怎么申请不到了?(非Android kye,网页地图key)
- jquery 获取vml 的问题 很纠结
- 各种需求,各种问~~
- 关于的数据处理的问题
- 连中彩票!!!
- document.getElementsByName问题
- JavaScript 怎么拷贝变量 防止修改?
- 我用document.execCommand('SaveAs')调用另存为对话框,发现不能将网页中的图片也保存下来!
- 如何用javascipt获得上一页面的绝对路径?用?号传过来的!
- ★★100分★关于Msxml2.DOMDocument的奇怪问题,读出来的XML内容有时不是最新的★★★
- 怎样固定我的表格大小
- JS与PHP问题
下面这样改应该可以了
function change(a,b,c){
var chk1=document.getElementById(a);
var txt1=document.getElementById(b);
var txt2=document.getElementById(c);
txt1.disabled=true;
if(chk1.checked){
txt2.disabled=false;
txt2.value=document.forms[0].txt1.value;
}else{
document.forms[0].txt2.value="";
chk1.checked="false";
}
}
不过最好加上form,这样比较好