Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Record inserted twice if image used for submit button


Message #1 by "Bill Barense" <kbattles@h...> on Thu, 9 Aug 2001 14:55:17 -0700
Let's say I have 3 submit buttons



1) TYPE="image"    -   onclick="save()"

2) TYPE="submit"20

3) TYPE="button"   -  onclick="save()"



The form has an input field and the page that processes the form just 

inserts a record into an MS Access table.



When the type=3D"image" button is used, 2 records get inserted, but when 

either the submit or button types are pressed, just one record is 

inserted, (as one would expect).  Any response.write's in the processing 

page only show once on the screen, so it doesn't seem like the whole 

page is being executed twice. 



Any thoughts???????    Thanks, Bill



HTML form code:



<FORM NAME="testForm" action="testProcess3.asp" method="POST">

<TR>

      <TD>Data: <input type=text name="txtData" size=15 

maxlength=25 ></TD>

</TR>

<TR>

  <TD colspan=3><INPUT TYPE="image" onclick="save()" 

src="images/save.jpg"> Type IMAGE - Once information has been 

verified, click to save</TD>

 </TR>

  <TR>

    <TD colspan=3><INPUT TYPE="submit" name=btnSave VALUE="Save" 

>

   - Type SUBMIT -Once information has been verified, click to save</TD>

 </TR>

 <TR>

   <TD colspan=3><INPUT TYPE="button" name=btnSave VALUE="Save" 

onclick=3D"save()">

     - Type BUTTON -Return to Donation Entry Screen w/out 

saving</TD>

 </TR>





Processing code:



Dim oConn

Set oConn = Server.CreateObject("ADODB.Connection")

oConn.Open "CCHS", "sa", ""

upData = request.form("txtData")



sSql1 = "Insert into test (test_data) VALUES ('"

sSql1 = sSql1 & upData & "')"



Response.Write (" test process 3 - insert sql : " & sSql1 & "<BR>")

oConn.Execute(sSql1)

oConn.Close

Set oConn = Nothing


  Return to Index