Difference between revisions of "JavaScript"
From AgileApps Support Wiki
imported>Aeric |
imported>Aeric |
||
Line 9: | Line 9: | ||
===Accessing Record Variables=== | ===Accessing Record Variables=== | ||
You access record data using the Document Object Model (DOM). | You access record data using the Document Object Model (DOM). | ||
[[Sample Order Processing System]], you might access a field in an OrderItem | In the [[Sample Order Processing System]], you might access a field in an OrderItem | ||
record like this: | record like this: | ||
:<syntaxhighlight lang="javascript" enclose="div"> | :<syntaxhighlight lang="javascript" enclose="div"> | ||
Line 16: | Line 16: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Or, using {{ | Or, using {{jQuery}} functions to shorten the syntax: | ||
:<syntaxhighlight lang="javascript" enclose="div"> | :<syntaxhighlight lang="javascript" enclose="div"> | ||
var val = $('input[name=item_quantity]').val(); | var val = $('input[name=item_quantity]').val(); |
Revision as of 21:43, 7 October 2011
This page provides general notes on using JavaScript in the platform.
About JavaScript
JavaScript is an object-oriented language that allows for functional programming. It is the language that drives much of the world wide web.
Learn more:
- JavaScript: The Good Parts (highly recommended)
Accessing Record Variables
You access record data using the Document Object Model (DOM). In the Sample Order Processing System, you might access a field in an OrderItem record like this:
- <syntaxhighlight lang="javascript" enclose="div">
var val = document.getElementById("item_quantity").valu; </syntaxhighlight>
Or, using Template:JQuery functions to shorten the syntax:
- <syntaxhighlight lang="javascript" enclose="div">
var val = $('input[name=item_quantity]').val(); </syntaxhighlight>
Accessing Variables in Lookup Records
Using JavaScript in the Platform
JavaScript can be used in a variety of ways
- Field Scripting - Add JavaScript code to take actions on a Field (On Change or On Focus)
- Form Scripting - Add JavaScript code to a Form (On Load or On Save)
- Post Selection JavaScript - Perform validations on Lookup Fields using JavaScript
- Action buttons - Add action buttons when displaying a record
- In a JSP/HTML Page - Make things happen on the client side to reduce the load on the server.
- Toaster Message - Add custom messages in toaster using JavaScript.