In this section: |
In a previous section, you added code to your FanClub application that deletes the name of a fan from the fannames data source.
However, you did not add any code asking your end users whether they are really sure about deleting this fan name.
You could easily create a confirmation form that asked your end users, "Are you sure you want to delete this fan?" If they click Yes, you execute the code to delete the fan. If they click Cancel, you return to Update_Form with the data source unchanged.
However, this means your application must reconnect to the WebFOCUS Server to get the confirmation form, which has the potential to slow down your application.
Instead of using Maintain forms and the Maintain language to create this confirmation form, you are going to use JavaScript. JavaScript (and its cousin, VBScript) is a mini-scripting language that is ideal for validating actions locally.
Note: You must have completed Creating an Update Form before you can do this section.
How to: |
What does the JavaScript function have to do?
You do this using the JavaScript confirm function.
You test what the end user response was using an if test. You execute DeleteFan using the IWCTrigger function, an Information Builders-supplied function that executes Maintain code from JavaScript.
if (confirm("Are you sure you want to delete this fan?")) IWCTrigger("DeleteFan"); else alert("Delete cancelled!");
Note: JavaScript is extremely case-sensitive. Make sure you type this syntax exactly as shown.
WebFOCUS |