Related

Denic

File comparison tools

Apache access log file

Quad Boot

Linux commands

Featured

Enea (Ersan Elmasa)

Name

Baby

I AM GETTING MARRIED

Fuck biology

Things I would like to do before death

Newest

MySQL database replace

Award

Graduation

Internet privacy

SSI to php

Random

MySQL database replace

Advice

Hattrick - IV.17 - Ersan 2 : 1 svrakino

Linux commands

There...

Return false

Sunday, July 05, 2009 13:41:16

Last Friday night as I was finishing web application for Constitutional Court of Bosnia and Herzegovina it was brought to my attention that certain entries were entered twice in the database. After quick investigation I found out that behavior was only in Internet Explorer and problem was double submission of form.
Culprit was input type image tag and onclick event. I have had code similar to this:
<input name='itiComment' value='Comment' type='image' src='/images/btnSubmit.jpg' onclick='document.forms[0].submit();'>
I have missed return value for onclick event, and since default browser behaviour for input type image is to submit form, my form was submitted twice (my submit call and default submit call). Setting event's return value to false corrected my problem and submitted form once.
Fixed code looks like this: <input name='itiComment' value='Comment' type='image' src='/images/btnSubmit.jpg' onclick='document.forms[0].submit(); return false;'>



Comments

Your email address:


*Your name:


Your website:


*Please type number shown on the right side of the text box:
verification image, type it in the box

*Comment: