怎么样让这些input的disabled=false?
我的意思是:
1、当选一个checkbox,它后面的input text 的disabled=false;
2、这个表单里的input有checkbox和text,text的名称由 "num_"和checkbox的vlalue值组合而成,
例如:num_2,num_3等;
3、我的js代码不能实现这功能,希望大家帮我看看,怎么样实现。谢谢了!
注意:由于这个form表单里的input是动态生成的,所以不可以直接使用形如form1.num_3.disabled=false;的代码,也就是说 num_3 应该是 num_x (x为对应行checkbox的value值)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>测试</title>
</head>
<body>
<form name='form1' method='post'>
<table width="69%" height="147" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="107">
<table align=center><tr>
<td><input type='checkbox' name='checkbox' value='2' onClick='chkclick();'></td>
<td>2</td>
<td><input type='text' name='num_2' value='100' disabled></td>
</tr>
<tr>
<td><input type='checkbox' name='checkbox' value='3' onClick='chkclick();'></td>
<td>3</td>
<td><input type='text' name='num_3' value='100' disabled></td>
</tr>
<tr>
<td><input type='checkbox' name='checkbox' value='1' onClick='chkclick();'></td>
<td>1</td>
<td><input type='text' name='num_1' value='100' disabled></td>
</tr>
<tr>
<td><input type='checkbox' name='checkbox' value='5' onClick='chkclick();'></td>
<td>5</td>
<td><input type='text' name='num_5' value='100' disabled></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><div align="center">
<input name="edit" type="button" id="edit" value="更改" onClick='record_edit();' disabled>
</div></td>
</tr>
</table>
</form>
<script language="javascript">
var oEle = document.getElementsByName("checkbox");
function chkclick()
{
for (var i=0;i<oEle.length;i++)
{
if(oEle[i].checked)
{
document.all.edit.disabled=false;
return;
}
}
document.all.edit.disabled=true;
}
function record_edit()
{
if(confirm('确认修改选择的记录吗\n\n确认修改?'))
{
document.form1.action="?";
document.form1.method="post";
document.form1.submit();
}
}
</script>
</body>
</html>