form链接问题,求解!!!!!
<script language="javascript">
function t( key, parentkey) {
var str = "";
if(key != 0) {
str = "<a href='categorydelete.jsp?id=" + key +"'>删除</a> "
}
url.innerHTML = str;
}
</script>
<table border="1" align="center">
<tr><td>
<form action="categoryadd.jsp" name="form" method="post">
<input type="hidden" name="action" value="add" />
<input type="text" name="pid" value="" readonly/>
<span id="url"></span><br>
<input type="text" name="name" /><br>
<textarea rows="4" cols="20" name="descr"></textarea><br>
<input type="submit" value="提交" />
</form>
</table>
当点击删除链接的时候,链接的页面categorydelete.jsp竟然访问的次数为两次。这是怎么回事??
categorydelete.jsp的代码
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="com.fzm.shopping.*" %>
<%@ include file="_sessioncheck.jsp" %>
<%
int id = Integer.parseInt(request.getParameter("id"));
System.out.println(id);//后台显示了两次相同的id;
Category.delete(id);//因为执行了两次这个页面得到的id相同,所以这里报错了;
%>
[解决办法]
没道理呀
[解决办法]
function t( key, parentkey)你这个函数是不是被执行过?
[解决办法]
<script language="javascript">
function t( key, parentkey) {
var str = "";
if(key != 0) {
str = "<a href='categorydelete.jsp?id=" + key +"'>删除</a> "
}
url.innerHTML = str;
}
</script>
为什么要写个js呢,而且你这parentkey参数也没用啊,直接下面这样不行吗
<%
int key=...;
if(key !=0){
%>
<a href='categorydelete.jsp?id=<%=key%>'>删除</a>
<%}%>
[解决办法]
你t()在哪里调用的?
[解决办法]