Hi, I have a problem on my page with code executing multiple times in IE and Opera, though it works in FF, Chrome and Safari. I am using the latest jQuery, the validation plugin and the form plugin. My code originates from the following html:
<form action="/case_study/php/survey_submit.php" id="mt_survey" method="post">
...
...
<fieldset id="submit_button_box">
<input id="submit_button" type="submit" value="Submit Case Data" />
</fieldset></form>
When I click the submit button it should run the following jquery:
$('#mt_survey').submit(function() {
if ( ($("#mt_survey").valid() == true) || confirm("Unfinished form, continue saving as temporary?")) {
$('#mt_survey').ajaxSubmit({
data: {table: "mt_data"},
target: '#messages',
success: function() {
$('#messages').fadeIn('slow');
$( 'html, body' ).animate( { scrollTop: 0 }, 0 );}
});
}
return false;
});
Now this works the first time I click submit. At which point I get the user to clear the form to enter the next dataset. They do so by:
$('#clear_form').click(function() {
$("#mt_survey").resetForm();
$("#messages").replaceWith('<div id="messages"></div>');
$("#messages").hide();
$("#escort_div").hide();
$("#transport_a_div").hide();
$("#transport_l_div").hide();
$("#item_div").hide();
$("#item2_div").hide();
$("label.error").hide();
$("#correction_button").attr('disabled', 'disabled');
$("#submit_button").attr('disabled', '');
});
Now once that is done, the form get's filled out again, and submit is clicked again. But this time in IE and Opera the code for it gets run multiple times. I know for sure it's runing multiple times since I checked by putting alerts in there, but mostly it is calling my "survey_submit.php" file multiple times and inserting data into MySQL. Any ideas why? It's been plaguing me for a long time and I see no reason why it's doing so.