Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

duplicate records being inserted in database table 2

Status
Not open for further replies.

PaulBricker

Programmer
Sep 25, 2002
3,554
US
I have 3 HTML pages with forms on them. The are very similar in style and structure. They all submit the data to ASP pages for the info to be inserted in my database tables. The ASP pages are all very similar as well. The problem is the data from one form gets inserted twice in the corresponding table. The other two pages work as expected. My input type tags are similar for all three as well except the form name is different in each onclick event.
Here is the input type code:
Code:
<input type="image" src="button3.jpg" value="submit information" onclick = "javascript:document.workrequestform.submit()">

Someone in the HTML forum thought that having similar on click events might be an issue. Any thoughts or suggestions would be appreciated.
Here is a link to the question I posted in the HTML forum
thread215-1424823

Thanks

Paul

 
Code:
<input type="image" src="button3.jpg" value="submit information" onclick = "javascript:document.workrequestform.submit()">

why not use something like this.
Code:
<img src="button3.jpg" alt="submit information" onClick= "document.workrequestform.submit()">

I don't exactly know a solution to your problem as I can't test it, but it could be that your input is being seen as a button and any button that is not declared a button will default to a submit unless you specify type="button". I'm not to sure but I think input type image is used for submit buttons, so you may be submitting twice? Does this make sense?

what the browser is seeing is a submit button with a javascript submit. Atleast i think, could you provide a link to your page?
 
I thought clicking on an image input automatically submitted the form. I'd guess you're submitting the page twice with that.

Lee
 
Unfortunately it's an intranet site so a link isn't going to help. I do understand what you are saying about the double submit happening because of the button and the javascript. My other two pages are set up the same way and they work properly so I'm not sure that will be it, but I'll try changing the code and see what happens.
I'll let you know.

Paul
 
Thank you both. I tried j4606's code and it worked well. I also changed my existing code as Lee suggested by removing the javascript portion and both methods seemed to solve the problem.
Figures, I looked at everything to solve this issue except the javascript.

Paul

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top