Topic: jsp (button和submit按钮的区别)

  Print this page

1.jsp (button和submit按钮的区别) Copy to clipboard
Posted by: zxg9129
Posted on: 2003-11-18 18:25

谁能告诉我button和submit按钮的区别,最好有例子说明。谢谢

2.Re:jsp [Re: zxg9129] Copy to clipboard
Posted by: 蓝色虾
Posted on: 2003-11-18 19:24

button按下去不一定会将白表单提交,有时候仅仅是跳转到其他页面
而submit是将整个表单以post提交。

3.Re:jsp [Re: zxg9129] Copy to clipboard
Posted by: wlai
Posted on: 2003-11-18 23:28

Submit钮按下会提交, Button 不会, Button 一般连接到 onClick 事件.

4.Re:jsp (button和submit按钮的区别) [Re: zxg9129] Copy to clipboard
Posted by: zxg9129
Posted on: 2003-11-19 12:43

<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function update(){
var id=0;
var arr ;
for(i=0;i<userRoleForm.elements.length;i++){
if(userRoleForm.elements[i].type=="checkbox"){
if(userRoleForm.elements[i].checked){
arr = userRoleForm.elements[i].value;
id = arr;
}
}
}
window.location="roleSelectAction.do?update="+id;
alert(id);
}

function Add(){

userRoleForm.action="Roles.jsp";

}
function Del(){
var id=",";
var arr ;
for(i=0;i<userRoleForm.elements.length;i++){
if(userRoleForm.elements[i].type=="checkbox"){
if(userRoleForm.elements[i].checked){
arr = userRoleForm.elements[i].value.split(":");
id += arr[0]+",";
}
}
}
window.location="rolesAction.do?del="+id;
alert(id);
}

</script>
</head>

<body>
<html:form action="/RoleListAction.do" method="post">
<p> </p>
<p> </p>
<table width="64%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="3%"> </td>
<td width="42%"> </td>
<td width="55%">
<html:submit value="增加" property="submit" onclick="Add()"/>
<html:button value="修改" property="button2" onclick="update()"/>
<html:button value="删除" property="button3" onclick="Del()"/>
<html:button value="权限" property="Submit4"/>
</td>
</tr>
</table>
<table width="64%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="7%"> </td>
<td width="40%">角色名称</td>
<td width="53%">描述</td>
</tr>
<bean:define id="roleLists" name="userRoleForm"
property="currentList" type="java.util.ArrayList"/>
<logic:iterate id="element" name="roleLists" type="cn.com.hkgt.bm.vo.RolesVO" offset="0">
<tr>
<td><input type="checkbox" name="role" value="<bean:write name="element" property="roleNo"/>">
<td><bean:write name="element" property="roleName"/></td>
<td><bean:write name="element" property="roleDecs"/></td>
</tr>
</logic:iterate>
</table>
</html:form>
</body>
</html:html>
在上面的程序中修改、删除的按钮该成submit就会出错, 所以我才会问起它们的区别为什麽呀?
<html:button value="修改" property="button2" onclick="update()"/>
<html:button value="删除" property="button3" onclick="Del()"/>


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923