CODECUBE VENTURES

Submit once button

Ever had users double click on that submit button resulting in double database entries? Here's the answer.

A simple javascript function that you can apply to the onClick event of a regular input="button"


function submitonce(button)
{
if (button.value != "Sending ...")
{
document.form1.submit();
}
button.value = "Sending ...";
}

The button that calls it would look like this


<input type="button" value="Submit" onclick="submitonce(this)" />

Notice also that it changes the text of the button to sending to let the user know it's working.

Latest post: Digging Up the First Version of CodeCube

See more in the archives