toggleAdded by IBM on October 10, 2012 | Version 1 (Original)
|Monitors a specific form option and detects any changes to the value of that option. This function can detect any change in an option, or can watch for specific changes. For example, you can create a toggle that detects when an option changes from on to off, or from Fred to Jim.
An error occurs if the specified form option does not exist.
Table 1. toggle parameters
toggle(reference, start, end)
|reference||Reference string||A reference to the option to monitor. For example, to monitor the value of a check box called "noChoiceAllowed", the reference would be noChoiceAllowed.value.|
|start||String||Optional. The starting condition for toggle. For example, set this to off to monitor when a check box is checked. Check boxes toggle from off to on when they are selected.|
|end||String||Optional. The ending condition for toggle. For example, set this to on to monitor when a check box is cleared. Check boxes toggle from on to off when they are cleared.|
Returns "1" if the specified change occurs in the specified option, or "0" if another change occurs.
Example In this example, toggle monitors a specific option for any change. Every time the value of "nameField" changes, toggle returns "1", and then a new time is entered into "timeStampField", using the now function.
In this example, toggle monitors a check box to determine if the check box is checked. If the value of the check box goes from off to on, the value of the label changes to "The box has been checked."
<value compute="toggle(nameField.value) == '1' ? now() : ''"
<value compute="toggle(check1.value, 'off', 'on') == '1' ?
'The box has been checked.' :
'The box has not been checked.'"></value>