button,submit, image的区别 点onclick后隐藏行

本文详细介绍了HTML中三种不同类型的表单按钮:button、submit及image,并通过实例展示了它们的功能区别,尤其是对页面提交行为的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<input type="button" name="Submit" value="显示表单button" onclick="showAddData()"/>
<input type="submit" name="Submit" value="显示表单submit" onclick="showAddData()"/>
<input type="image" alt="add" src="<%=request.getContextPath() %>/images/btnImg/btn_add.gif" onclick="showAddData()" />

------------------------------

1.  type="button" onclick=onclick="showAddData()"      不会提交页面,只对按钮有效.

2.  type="submit" onclick=onclick="showAddData()"      会提交页面

3.   type="image" onclick=onclick="showAddData()"      会提交页面

---------------------------------

例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>关于“显示表单”与“关闭表单”的演示</title>

<script type="text/javascript">
function showform()
{
document.getElementById("lizi").style.display="block";
}
function closeform()
{
document.getElementById("lizi").style.display="none";
}
</script>
</head>

<body>
<form id="form2" name="form2" method="post" action="">
  <table width="98%" border="1" cellspacing="0" cellpadding="0" >
    <tr>
      <td height="68"><label>
        <input type="button" name="Submit" value="显示表单" onclick="showform()"/>
        <input type="button" name="Submit2" value="关闭表单" onclick="closeform()"/>
      </label></td>
    </tr>
    <tr>
      <td height="63">wwwwww</td>
    </tr>
    <tr id="lizi" style="display: none;">
      <td height="63"><input type="text" name="test" value="aaa" /></td>
    </tr>
  </table>
</form>
</body>
</html>

 

转载于:https://www.cnblogs.com/wj-wangjun/archive/2010/02/05/1664377.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值