不页面跳转是不行的.
大不了跳向本页面.
不要用两个submit.
这样用的话要用两个body.
用button来出发javascript事件.
<input type="button" name="new" value="新增" onclick="javascript:add()">
<input type="button" name="edit" value="新增" onclick="javascript:modify()">
大不了跳向本页面.
不要用两个submit.
这样用的话要用两个body.
用button来出发javascript事件.
<input type="button" name="new" value="新增" onclick="javascript:add()">
<input type="button" name="edit" value="新增" onclick="javascript:modify()">
Http是无状态的,在客户端如果你不提交是不可能调用服务器 端的javabean的
你这个就提交到本页面处理啦
onclick="javascript:add()"> //不懂哦。
请问,如何在avascript里调用javabean,请把代码写上,谢谢!!
如
<script language="javascript">
function check()
{
...
}
</script>
则
<input type="button" name="new" value="新增" onclick="check()">请问能在javascript里调用javabean吗?
如:
<%@ page contentType="text/html; charset=GBK" language="java"%>
<html>
<head>
<title>jisuan</title>
</head>
<jsp:useBean id="user" scope="page" class="test2.JisuanBean" />
<jsp:setProperty name="user" property="*" />
<%
String act = request.getParament("act");
if(act.equals("add")) {
user.A();
}else if(act.equals("modify")) {
user.B();
}
%>
<script language="javascript">
function add(){
with(form){
form.act.value="add";
form.action="jsp1.jsp";
form.submit();
}
function modify(){
with(form){
form.act.value="modify";
form.action="jsp1.jsp";
form.submit();
}
}
</script>
<form method="post" name="form">
编号<input type="text" name="x">
<input type="button" name="new" value="新增" onclick="javascript:add()">
<input type="button" name="edit" value="新增" onclick="javascript:modify()">
<input type="hidden" name="act" value="1">
</form>
</body>
</html>
function sendRequestPost(url, data){
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); var method = "POST";
xmlhttp.open(method, url, false);
xmlhttp.setrequestheader("content-type","application/x-www-form-urlencoded");
xmlhttp.send(data);
result = xmlhttp.responseText;
return result;
}
其它的代码我就不想写出来了...这种方法的限制就是ie5.0加上MSXML2.dll
一般ie5.5以上都可以很好的使用这个函数...
看看这个帖子吧http://search.csdn.net/Expert/topic/1381/1381310.xml?temp=.1570551