takes note of this technique
In style of PayPal! Been wonderin if I could find out hwo to do it and I found it!! 🙂
Anyway I would just like to add comment on how this can only be done in JavaScript and not possible in PHP.
Ok basically, JavaScript is a client-side script. PHP is a server side script.
Let's imagine we have a simple javascript and a simple PHP script that both display the same "Hello, world" string.
This page resides on your server. When requested, the server takes this page and makes sure it has the .php extension so it knows it must process the script before sending. It looks at the page code and notices JavaScript but knows this can only be done with user input so it leave it on the page. It then sees the PHP so it processes and sends the page to the browser leaving it without the PHP so that it looks like an ordinary html.
For instance, the page might have
echo "<p>Hello, world!</p>"
The server will know to print or type-in the echos as if it was already saved on the page. If you were to go to this page's URL and view source you will see no PHP whatsoever.
BUT, if Javascript is ont he page, the server ignores it because it is client-side script that must be processed byt he browser on the surfer's machine.
The client views the page and whatever happens, happens. In your case with the onClick...the browser will wait until the onClick has occured before going ahead with the relevant actions.
Recap
PHP is only processed on the server upon request and upon page movement (I don't know how to explain this. Forms for example is movement. The age changes and variables are passed on). The client does not process any PHP.
JavaScript resides in the page code on client machine untilt he user/machine/browser interacts with the code in some way and the relevant action takes place straight away.
God I outta be a teacher...
I wrote this because AJPayne did not reply that he has returned, the script worked or any acknowledgment so I'm guessin he/she is either damn rude or hasn't come back. Oh or that they don't udnerstand.
That's why I wrote this plus for other newbie's reference 😃