一个小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
%>
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
%>
<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>
如果你已经提交了表单到url 再刷新 才会提交再请求
...
rs.addnew
..
rs.update
%>
所以要加个判断,如果不是按钮,是 <input type="submit" name="sub">就可以用request("sub")<>"" then...现在变成了BUTTON按钮了
你要加个判断?if(document.getElementById('按钮的ID').type == 'submit')
{
}else if(document.getElementById('按钮的ID').type == 'button'){}