Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 21st, 2005, 05:39 AM
Authorized User
 
Join Date: Jul 2003
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I flag an error message on a Submit button?

Hi there

Apologies if this is a really basic question but my knowledge of Javascript extends to copying bits and pieces off pages and amending for my needs! I'm a total newbie i'm afraid.

So, can anyone help me with the following problem.

I have an Ordering page that submits info to a database on clicking a Submit button. As there is a lot of data to be passed to the database, it sometimes takes a while before submitting and moving to a Thank You page. We are noticing that people are obviously thinking that the button's not working, and clicking on it again. This obviously submits the info again and causes multiple entries in the database.

I would like to be able to have an alert box pop up if the user clicks on the submit button for a 2nd time i.e. they click on submit, think nothing's happening, click on it again, message pops up saying 'currently processing order', data isn't submitted for a second time. Once first data has submitted successfully, page changes to Thank You page.

Any ideas?

I suppose another way of doing this would be to 'hide' the button once it had been clicked, and 'show' a message to say 'processing order, please wait' but I don't know how I would do this either!

Again, any ideas?

Thanks in advance

Lucy
 
Old January 21st, 2005, 06:24 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Lucy,

This should do want you want, but you may have people who don't have javascript enabled etc.
IMHO you should always try to prevent the double entries being made in the db on the server side as well.
Code:
function DisableSubmit(pForm){
    pForm.onsubmit = new Function("alert('currently processing order'); return false;");    
    return true;
}

...

<form onsubmit="return DisableSubmit(this);">
HTH,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
Make a image button as default submit button toshi ASP.NET 1.0 and 1.1 Basics 1 June 1st, 2006 05:25 AM
Submit Button trusslady Infopath 2 January 6th, 2006 05:19 PM
submit-button grstad Javascript How-To 1 May 25th, 2005 08:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.