Things I would like to do before death
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;'>