Change a button after e-mail

breeze351
breeze351 used Ask the Experts™
on
I have a page with a button that sends an e-mail with the data on the page.  The page that sends the e-mail just returns to the original page.  How do I alert the user that they sent the e-mail (grey out or something else).  Should I set a $_SESSION var?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016
Commented:
Yes, a session variable is appropriate for this.
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
There are a couple of options - firstly if the page that processes the click is the same as the page that renders the form then simply gray out the button on the render of the page - you will know that you have sent the email so you can use that to build the logic around rendering out a grayed out button.

Option 2 - send the request by AJAX and gray out the button with JavaScript

Author

Commented:
Got it. Thought that there might be an easier way.
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
In my view AJAX is the easiest option - your backend script only needs logic for sending mail and returning status - no need for rendering an interface. The client script is also very easy - a single AJAX call with a status check in the callback.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial