Hi,

In the below code snippet, frmMain is the name of my form. For some reason this form is submitted twice at random times. There is no way that the user could click the button twice. But still duplicate submission happens occasionally. Unable to reproduce the bug during testing and could not figure out why this is happening. Does anyone get a hint of why this could be happening?

$('frmMain').addEvent('click', function(e)
{
/**
* Prevent the submit event
*/
new Event(e).stop();

/**
* This empties the log and shows the spinning indicator
*/
var log = $('log_res').empty().addClass('ajax-loading');

/**
* send takes care of encoding and returns the Ajax instance.
* onComplete removes the spinner from the log.
*/
this.send(
{
update: log,
onComplete: function(responseText)
{
log.removeClass('ajax-loading');
recordId = "";

var result = responseText;
if(result.indexOf("Approved") >=0)
{
document.getElementById("log_res").innerHTML ="<b style = 'color:blue'>Leave has been approved successfully</b>";
document.getElementById("pStatus2").innerHTML ="<b style = 'color:blue'>Leave has been approved successfully</b>";
}

if (result.indexOf("Rejected") >= 0)
{
document.getElementById("log_res").innerHTML ="<b style = 'color:red'>Leave has been Rejected successfully</b>";
document.getElementById("pStatus2").innerHTML ="<b style = 'color:red'>Leave has been Rejected successfully</b>";
}
setTimeout ("location.reload(true);",3000);

//Remove the click event
$('frmMain').removeEvents('click');

}
});
});