OnClick vs OnChange causes different behavior inserting records into the database with Windows IE
Posted on 2004-09-27
I'm stumped. I've got a text box with an 'Add' button next to it. The text box has an onChange = doSubmit2('Save'). The Add button has an onClick=doSubmit2('Save'). The doSubmit2 inserts a record into a database table. If I use the onChange event, it works just fine. If I use the onClick event, two records are inserted into the database. This only happens under Windows IE (I'm using 6.0.2900 on Windows XP SP2). It doesn't happen on any of the Mac browsers (IE, Safari, Mozilla) and it doesn't happen on Mozilla on Windows XP SP2). I've tested under IE 6.0.2800 and 5.50.xxx on Windows and the same behavior happens.
Going into the cfquery tag, I don't have any records in the database. Immediately after the cfquery tag, I've got two identical records in the database. I've used the following syntax for my insert "insert into table_name (field1, field2, field3) values (element1,element2,element3)", as well as "insert into table_name set field1 = element1, field2 = element2, field3 = element3". There are no triggers on the database.
I've also removed the cftry/cfcatch tags at this point. I can catch the double insertion with cftry/cfcatch, but in the case of the User trying to insert two records, I'd like to actually show an error message.
Anyone have any ideas?