Accessing a Drop-Down Selection

  To add a JavaScript script to the drop-down box to display the selection in an alert:

  1. Open Sample1mod.bqy, activate the Limits Dashboard section, and change to Design mode.

  2. Double-click DropDown1 to display the Properties dialog box, change the Name field to drp_Territory, and then click OK.

    Tip:

    To clarify the purpose of control objects when viewed through the object model, adopt a naming convention that includes the type of object (drp_ for a drop-down box) and the type of information or action associated with the object (Territory for database Territory options).

  3. Open the Script Editor for the drop-down box.

    Right-click drp_Territory (changed from DropDown1)—which should still have handles around the box—and select Scripts from the shortcut menu.

    Note:

    This rest of this exercise shows how to click through the object model to associate a script to drp_Territory, a Limits Dashboard object. The script will apply the Item method, using a pointer to the selected item (SelectedIndex) as the method argument.

  4. Expand Methods and Properties for Limits DashboardDashboard Objects., then drp_Territory.

    To see both methods and properties for drp_Territory, scroll down, or click the striped arrow below the scroll bar to expand the Elements pane.

  5. Double-click the Item method to enter drp_Territory.Item() in the Script Editor.

    drp_Territory.Item()
  6. Place the cursor inside the parentheses of the Item method, and then double-click SelectedIndex from the Properties folder.

  7. Type a semicolon (;) and a return [Enter] at the end of the line.

    The line now reads:

    drp_Territory.Item(drp_Territory.SelectedIndex);

    The SelectedIndex property of a drop-down box is the index number (or position number) of the selected value. Item() uses this argument to return the text the user selected.

  8. Add a new statement using the Alert method with the drop-down selection as its argument.

    1. Type Alert() or double-click Alert from within Application, then Methods.

    2. Copy the first JavaScript statement and paste it inside the Alert method’s argument parentheses.

    3. Delete the semicolon from within the argument.

    4. Type a semicolon (;) and return [Enter] at the end of the statement.

  9. Click OK to save the current script and close the Script Editor.

  10. Toggle to Run mode, click the arrow in the drp_Territory drop-down box and select an item.

    Selecting an item causes a popup message to is displayed.

    The Alert method displays a popup message that contains the name of the item selected from the drop-down box.