Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 21st, 2005, 05:39 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old January 21st, 2005, 06:24 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:27 PM.


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