页面:
<head>
<script type="text/javascript">
function del()
{
window.confirm("您确定要删除吗?");
var a = document.getElementById('hid');
location.href="se.do?operate=del";
document.forms[0].submit();
}
</script>
</head>
<body>
<logic:notPresent scope="request" name="allPhyle">
<jsp:forward page="/se.do?operate=searchAll"></jsp:forward>
</logic:notPresent>
<form action="se.do" method="post">
<table>
<logic:iterate scope="request" name="allPhyle" id="phy">
<tr>
<td>
<input type="hidden" name="hid" value="${phy.zzid}"/>
<a href="" onclick="del()">JS删除</a>
</td>
</tr>
</logic:iterate>
</table>
</form>
</body> Action:
int id = Integer.parseInt(request.getParameter("hid"));
Phyle phy = biz.findbyId(id);
biz.delOne(phy);
return new ActionForward("/index.jsp");
我想得到页面上隐藏域hid里存的值,用来删除时候做id,不过我这么取值,id得不到,大家帮我看看,怎样能在Action里取得隐藏域hid中的数值呢?
<head>
<script type="text/javascript">
function del()
{
window.confirm("您确定要删除吗?");
var a = document.getElementById('hid');
location.href="se.do?operate=del";
document.forms[0].submit();
}
</script>
</head>
<body>
<logic:notPresent scope="request" name="allPhyle">
<jsp:forward page="/se.do?operate=searchAll"></jsp:forward>
</logic:notPresent>
<form action="se.do" method="post">
<table>
<logic:iterate scope="request" name="allPhyle" id="phy">
<tr>
<td>
<input type="hidden" name="hid" value="${phy.zzid}"/>
<a href="" onclick="del()">JS删除</a>
</td>
</tr>
</logic:iterate>
</table>
</form>
</body> Action:
int id = Integer.parseInt(request.getParameter("hid"));
Phyle phy = biz.findbyId(id);
biz.delOne(phy);
return new ActionForward("/index.jsp");
我想得到页面上隐藏域hid里存的值,用来删除时候做id,不过我这么取值,id得不到,大家帮我看看,怎样能在Action里取得隐藏域hid中的数值呢?
<input type="hidden" id="hid" name="hid" value="${phy.zzid}"/>function del()
{
window.confirm("您确定要删除吗?");
var a = document.getElementById("hid").value;
window.location.href="se.do?operate=del&hid="+hid;
}
错了...function del()
{
window.confirm("您确定要删除吗?");
var a = document.getElementById("hid").value;
window.location.href="se.do?operate=del&hid="+a;
}
谢谢您的回复
不过我现在的问题是 我的隐藏域hid传到action里面的值是一个字符串"[object]",我并没有得到我想要的id值,请问这是为什么啊?
function del(zzid)
{
window.confirm("您确定要删除吗?");
window.location.href="se.do?operate=del&hid="+zzid;
}
function del(zzid)
{
window.confirm("您确定要删除吗?");
window.location.href="se.do?operate=del&hid="+zzid;
}
这样就可以了