Book Image

Oracle APEX Cookbook : Second Edition

Book Image

Oracle APEX Cookbook : Second Edition

Overview of this book

Table of Contents (21 chapters)
Oracle APEX Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Adding JavaScript code to your application


JavaScript can also be used for client validation. We will build a validation on the salary field. When the user raises the salary by more than 10 percent, an alert box will appear where the user can confirm the salary.

Getting ready

Make sure you have a tabular form based on the EMP table. At least the salary column should be present in the form.

How to do it...

  1. In the Application Builder, go to the page based on the EMP table.

  2. In the Regions section, click on the Report link:

  3. Click on the Edit icon (the pencil) near the SALARY column:

  4. In the Column Attributes section, enter the following in the Element Attributes text field:

    onfocus=remember_oldsal(this.value); onchange=validate_sal(this.id,this.value);
    [9672_03_01.txt]
  5. Click on the Apply Changes button, and after that click again on it.

  6. In the Page section, click on the Edit icon.

  7. In the HTML Header and HTML Body Attribute section, enter the following in the HTML Header textarea:

    <script type="text/javascript...