Difference between revisions of "JavaScript"

From LongJump Support Wiki
imported>Aeric
imported>Aeric
Line 22: Line 22:


===Accessing Variables in Lookup Records===
===Accessing Variables in Lookup Records===
Records in an object commonly have a [[Lookup]] to records in another object. For
example, in the [[Sample Order Processing System]], OrderItem records have a lookup
to the Order they are part of, as well as lookup to the ProductInventory object,
which holds details about the item the customer wants to order.
To access a field in the lookup target record, you use "dot notation", following this pattern:
:<syntaxhighlight lang="javascript" enclose="div">
{current_record_lookup_field}.{target_record_field}
</syntaxhighlight>
For example, In an OrderItem record, then, you might get the quantity on hand like this:
:<syntaxhighlight lang="javascript" enclose="div">
var val =  document.getElementById("related_to_productInventory.quantity_on_hand").valu;
</syntaxhighlight>
Or, using {{jQuery}} functions to shorten the syntax:
:<syntaxhighlight lang="javascript" enclose="div">
var val = $('input[name=related_to_productInventory.quantity_on_hand]').val();
</syntaxhighlight>


==Using JavaScript in the Platform==
==Using JavaScript in the Platform==

Revision as of 21:48, 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:

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:

var val =  document.getElementById("item_quantity").valu;

Or, using Template:JQuery functions to shorten the syntax:

var val = $('input[name=item_quantity]').val();

Accessing Variables in Lookup Records

Records in an object commonly have a Lookup to records in another object. For example, in the Sample Order Processing System, OrderItem records have a lookup to the Order they are part of, as well as lookup to the ProductInventory object, which holds details about the item the customer wants to order.

To access a field in the lookup target record, you use "dot notation", following this pattern:

{current_record_lookup_field}.{target_record_field}


For example, In an OrderItem record, then, you might get the quantity on hand like this:

var val =  document.getElementById("related_to_productInventory.quantity_on_hand").valu;

Or, using Template:JQuery functions to shorten the syntax:

var val = $('input[name=related_to_productInventory.quantity_on_hand]').val();

Using JavaScript in the Platform

JavaScript can be used in a variety of ways

Reference Information