当前位置:Gxlcms > JavaScript > JSbutton按钮实现submit按钮提交效果

JSbutton按钮实现submit按钮提交效果

时间:2021-07-01 10:21:17 帮助过:14人阅读

今天在使用表单是同时使用POST更新、删除操作。然而form表单的 submit 且一旦提交则全部提交,所以想到的实现方法就是 使用button实现,代码实现见如下:

form设置:

<form method=”post” name=”linkform”>

隐藏的act方法设置,代码如下:

<input name=”act” type=”hidden” />

最后关键的是 button的设置,更新按钮,代码如下:

<input onclick=”document.linkform.act.value='update'; document.linkform.submit();” name=”update” type=”button” value=”更新” />

删除按钮,代码如下:

<input onclick=”if(confirm(‘你确定要删除数据吗?')){ document.linkform.act.value='delete'; document.linkform.submit();return true;}return false; ” type=”button” value=”删除” />

以上所述是小编给大家介绍的JS button按钮实现submit按钮提交效果

人气教程排行