Database Reference
In-Depth Information
5.
Set Condition to JavaScript expression .
6. Locate and open the file ch16_javascript.txt . This file can be
found where you unzipped the files associated with this topic.
Examine the JavaScript string that is being used as the body of the condition. This
may seem very cryptic at first, but when it's broken down, it's quite straightforward.
Let's look at it in pieces:
this.triggeringElement.options[this.triggeringElement.selectedIndex].text
== 'CLOSED'
The keyword this references the JavaScript event that kicked off the chain of events
to start with, and triggeringElement references the item on the page that was at the
root of the event. So in this case, this.triggeringElement is talking about
P210_STATUS_ID .
Here's where a little developer knowledge has to be introduced. Being the deve-
loper, you know that P210_STATUS_ID is a select list, and that a select list has from
1 to many values the user can select. In HTML, these values are called options .
Because of the way you've declaratively defined the P210_STATUS_ID select list,
only one option can be selected at a time. You can access the option that is currently se-
lected on the page by using the JavaScript this.triggeringElement.selectedIndex . The
square brackets use that index to reference the selected option from the
P210_STATUS_ID select list.
Although you could reference the value of the selected option, that would only give
you the ID of the selected status. You'd then have to make a round trip to the database
to find out the text status. Instead, you can use the .text JavaScript method to get the
text that the select list is displaying to the end user and see what they selected.
Once you have that, you can then compare it to the value you're looking for, which
is CLOSED .
7. Copy the contents of the file into Value , as shown in Figure 16-15 ,
and click Next .
 
Search WWH ::




Custom Search