jsp文件传值给js方法
rs.last();
int length = rs.getRow();
rs.beforeFirst();
rs.next();
out.print("<table border='2'>");
for(int i=1;i<=length;i++)
{
out.print("<tr>");
for(int j=1;j<=10;j++)
{
out.print("<td>");
if(j==1)
{
if("start".equals(rs.getString(j).trim()))
{
out.print("<img src='image/startexecute.png' alt='关闭' id='End' onclick='changeImg1(this)'/> ");
}
else
{
out.print("<img src='image/stopexecute.png' alt='开启' id='start' onclick='changeImg3(this)'/>");
}
}
else
{
out.print(rs.getString(j));
out.print("</td>");
}
}
rs.next();
out.print("</tr>");
}
out.print("</table>");
我想在点击图片调用js方法时将此时的i值传到js方法里,怎么解决
js:
function changeImg1(img1){
img1.src="image/stopexecute.png";img1.alt="关闭";
window.location.href="update.jsp";
alert("设备关闭成功");
}
[解决办法]
lz贴的是java代码吧,呵呵,不好意思
out.print("<img src='image/startexecute.png' alt='关闭' id='End' onclick='changeImg1(this"+ i + ")'/> ");