您现在的位置是:首页 > 电脑技术查询 > web开发

js提交数据,该怎么处理

编辑:chaxungu时间:2022-10-02 23:14:24分类:web开发

js提交数据
一个小BUG,就是当页面点刷新的时候,数据又再一次提交到数据库中,我只希望当用户点button按纽的时候,数据才插入到数据库里,如何修改呢?

<script language="javascript">
function pd()
{
this.form1.submit()
}

<form action="#" method="post" name="form1">
<table>
<tr>.....
</table>
<center><input type="button" onclick="pd()" value="提交数据">
</form>
<%dim conn,rs
..
rs.addnew
..
rs.update
%>

------解决方案--------------------
HTML code<html><head><head><title></title><meta content="text/html; charset=utf-8" http-equiv="Content-Type"></head><body><form action="aaa" method="post" name="form1"><input type="button" value="click me" onclick="pd()" /></form><script> function pd() { document.form1.submit() }</script></body></html>
------解决方案--------------------
button提交的时候,多传个参数过去,标识,它是button提交的。后台根据这个参数判断一下。