I've noticed that for some reason IE submits forms on my drupal site twice. It's horrible because some nodes created with this browser are automatically created twice! User registration form is submitted twice and drupal tries to create two accounts for one form submit!
Any ideas how to prevent this? can this be my theme's issue that automatically replaces submit buttons with images?

for form submission i use combination of html and javascript - this is because funny drupal behavior that checks the value of submit button :/
so my submit button-images look like this:

<input src="image.jpg" onMouseOut="this.src='image.jpg';" onMouseOver="this.src='image2.jpg';" type="image" name="_op" value="Submit"  class="form-submit" onClick="return imageSubmit(this,&#039;op&#039;,&#039;Search&#039;)" />

and the js looks like this:

function imageSubmit(elm, nam, val){
  var input = document.createElement('input');
  input.type = 'hidden';
  input.name = nam;
  input.value = val;
  elm.form.appendChild(input);
  elm.form.submit();
  return false;
}

Please can anyone help? i've been trying to solve this for days without luck. this is killing me. users receive double e-mails on registration, nodes are duplicated and i have no idea why!

Comments

dwees’s picture

Try switching the code for your onclick handler to an onsubmit handler in the attributes of the form element.

It's possible that IE is reading the JS correctly, then not actually cancelling the progation of the submit event like it should, but I think this all works fine if it's in the submit handler.

ie:

<form action="blah" onsubmit="return yourOnSubmitHandler();" />
siliconmind’s picture

this wont work as we do not know which button will be clicked to submit the form. you need to know that to set correct value for the input named 'op' which drupal is checking for.

but still, how you'd explain why only some nodes are added twice and some not?

oh and btw, user gets only one message saying that new node was added and watchdog also logs one message. but node is inserted twice. how can i prevent this duplicates?

lipinggm’s picture

It happens to me too. I use the similar submit approach like you:

IE submits form twice (randomly) to Weblogic server, Weblogic throws 'javax.servlet.jsp.JspException: Connection reset by peer: socket write error' Exception when duplicated request submitted. It does not hapend in Firefox.

I am wondering if you find solution yet?

Thanks,

varunv’s picture

Basically, when a user clicks on a button, I was getting the form handler getting triggered twice (like you all). however, to fix it, all I did was get the button and disable it through the DOM.

So -

var submitButton1 = document.getElementById("submitButton");
submitButton1.disabled=true;

// submit the form
var formElement = document.getElementById("orderForm");
formElement .submit();

would do the trick !!

YK85’s picture

Hello,

I am having trouble with users accidentally pressing 'Create Account' twice at user register and it gives an error that their username is already used, as it created it on the first click and trying to create again on the second click.

I tried http://drupal.org/project/block_submit but it didn't work for IE at all =(
Can anyone please help?

Thank you!