In some situations, you would like to be able to cancel an operation you have started with a button. For example, you may have a script that copies information from one record to another. When users incorrectly click any button tied to a script that performs automated actions, you run the risk of invalid information being in your database.
Use the confirm method to ask the user to make a decision that requires either an OK or a Cancel. The message argument specifies a message that prompts the user for the decision. The confirm method returns true if the user chooses OK and false if the user chooses Cancel.
| if(confirm("Are you sure you wish to copy these jobs?")){ |
| // Continue with the operations |
| } |
| else { |
| // The user clicked on "Cancel" |
| } |