To declare a variable and assign the drop-down selection:
Toggle to Design mode, open the Script Editor on drp_Territory.
Type var Selection= at the beginning of the first line of the existing script.
var Selection=drp_Territory.Item(drp_Territory.SelectedIndex);
This declares a new variable Selection, and assigns the user’s selection to it.
Test the script by toggling to Run mode and selecting an item from the drop-down box.
An alert containing the name of the selected item should is displayed.
If the alert displays “undefined”, the alert argument has not been assigned a value. This is most likely a typo: If the variable is defined with a capital “S” for Selection, the variable in the alert argument must also have a capital “S”.
The exercises in this section used JavaScript and the Intelligence Client object model to access a user’s selection in a drop-down box. The Item method, with SelectedIndex as the argument can be acted on directly, or a variable can hold the selection, clarifying the JavaScript logic: get the selection, act on it.