这里我希望能够得到动态的文本框的id,不希望使用指定的id 但是我这里要是使用传递参数的方式就没办法达到效果
这个不能运行
function a(i){
var tds = document.getElementsByTagName("input");
document.all.tds[i].id.removeAttribute('disabled');
}
这个能运行
function a(){
document.all.name2.removeAttribute('disabled');
}
这个不能运行
function a(i){
var tds = document.getElementsByTagName("input");
document.all.tds[i].id.removeAttribute('disabled');
}
这个能运行
function a(){
document.all.name2.removeAttribute('disabled');
}
解决方案 »
- 新手求教:Hibernate Annotation 的简单配置问题
- 介绍一本书 在 myeclipse 环境下开发 JSP 的书
- 紧急求助!我的这个代码究竟出错在哪了??
- jsp中的button,如何点一下然后传递参数,但是不跳转呢?
- 请指点指点我,JAVA的变量问题搞不通~~
- 邮件程序登录时提示以下错误请教各位是什么原因?
- 问一下在struts1.2中ActionMessages类,还有,我想在javabean中使用正则表达式的问题
- 一个Java程序员的选择??
- Generate外包工作室诚邀加盟(最新)
- 数据库连接错误,怎么解决呀
- freemarker循环输出json时,怎么去掉最后一行后面的逗号?
- struts 传值
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
function get_td_id(){
var tds = document.getElementsByTagName("input");
var length = tds.length;
for(var i=0;i<length;i++){
alert(tds[i].id);
}
}
window.onload = function(){
get_td_id();
}
function a(i){
alert(i);
var tds = document.getElementsByTagName("input");
alert(tds[i-1].id);
document.all."+tds[i]+".id.removeAttribute('disabled');
}
function a(i){
alert(i);
var tds = document.getElementsByTagName("input");
alert(tds[i-1].id);
document.all.name2.removeAttribute('disabled');
}
</script>
</head>
<body> <p> </p>
<table width="403" border="1">
<tr>
<td width="85">编号</td>
<td width="249">选项</td>
<td width="47">操作</td>
</tr>
<%
for(int j=1;j<4;j++){
%>
<tr>
<td><%=j %></td>
<td id="<%=j %>"><label id="<%=j %>">
<input type="text" name="name" id="name<%=j%>" value="这是第<%=j %>个" disabled="disabled">
</label></td>
<td><a onclick="a(<%=j %>)">修改</a></td>
</tr>
<%
}
%>
</table>
<p> </p>
</body></html>
function a(i){
var tds = document.getElementsByTagName("input");
var name = tds[i-1].id;
document.getElementById(name).removeAttribute('disabled');
}