Application Techniques

Confirming a Request before Submitting it to the Server

How to use JavaScript to verify a user request on the client (browser) before sending it to the server.

About this technique



HTML Client Techniques> JavaScript


You'll learn about:

You can run this technique code from:

NOTE   First make sure that database is running on your localhost SilverStream Server

Related reading

See the chapter on advanced page topics in the Programmer's Guide

Adding JavaScript to a page   Top of page

The following describes how to add JavaScript code to a page.

  1. Invoke the Properties dialog box of the page.

  2. In the Page tab, select the Scripting field and click the Javascript button. This brings up the JavaScript editor.

Writing JavaScript for a button click   Top of page

The following code shows the JavaScript that launches a dialog box upon the Button1 button click.

  method handle_Button1_onClick() 
     if (confirm("Are you sure you want to execute this code?")) 

Notes about the code

Handling a submit request   Top of page

The following code runs when a Submit request is processed by the server. This request was sent by the JavaScript when the user clicked the OK button in the Confirm dialog box.

  private void handle_Button1_pageActionPerformed(ActionEvent evt) throws Exception 
     Hashtable message = new Hashtable(); 
     message.put("MESSAGE", "You answered OK after you clicked Button1."); 
     message.put("URL1", "SilverStream/pages/pgConditionalSubmit.html"); 
     message.put("LINK1", "Return to pgConditionalSubmit.html"); 
     showPage("../../message.html", null, null, message); 

Notes about the code

Copyright © 2000, SilverStream Software, Inc. All rights reserved.