DropDownBox PropertiesJavascript control


Enables rendering a dropdown box control as a "Javascript control", which allows additional customization of the look of the dropdown box control and gives access to JavaScript methods to manipulate the choices in the control.


By default, the dropdown box control is rendered using the HTML input control (e.g. <select> <option>...</option> ... </select>). The default HTML input control is difficult to customize the look and feel. It also lacks JavaScript methods for repopulating the dropdown box options easily.

The Javascript control option converts the dropdown box control into a JavaScript dropdown box control. As a JavaScript control, Alpha Anywhere creates a JavaScript object you can use in client-side scripts to manipulate the options in the control. You also can also add custom CSS classes or inline-styles to customize the look of the dropdown box control.

For example, in the images below, the dropdown box control has been rendered with a custom In-line style.


To enable the Javascript control option, check the Javascript control property in the Property Sheet.


The Settings property is shown when Javascript control is checked. Settings can be used to customize the look (i.e. CSS) for the dropdown box options.


Configuring Control Settings

Once enabled, you have access to the following options to configure the control:

Getting the Control's JavaScript Object

To get a pointer to the dropdown box's JavaScript object, use the [{dialog.object}.getControl()] method. For example:

var dropdownObj = {dialog.object}.getControl("DROPDOWNBOX_1");
if (dropdownObj) {
    ' Object exists! Can call methods on it.

Once you have a pointer to the object, you can call methods on the object, such as the populate() method to repopulate the choices in the control.

The following methods are available:


Updates the control's choices. This method can be used to replace or add the control's options.

var obj = {dialog.object}.getControl('DROPDOWNBOX2');
if (obj) {
    var arr = [];
    var keep = false;
    var animate = true;

Redraws the control. The refresh() method is usually called after repopulating the control's choices using the populate() method.

var obj = {dialog.object}.getControl('DROPDOWNBOX2');
if (obj) {

Enables or disables the control. The control can also be enabled or disabled using the {dialog.object}.setDisabled() method.

var obj = {dialog.object}.getControl('DROPDOWNBOX2');
if (obj) {
    if (Reflect.has({dialog.object}._myvars, 'dropdownEnabled') == false) {
        {dialog.object}._myvars.dropdownEnabled = true;
    {dialog.object}._myvars.dropdownEnabled = !{dialog.object}._myvars.dropdownEnabled;

See Reflect (MDN) to learn more about this native built-in JavaScript object.


Sets the control's value. The value can also be set using the {dialog.object}.setValue() method.

var obj = {dialog.object}.getControl('DROPDOWNBOX2');
if (obj) {
    var value = parseInt({dialog.object}.getValue('DROPDOWNBOX2'),10);
    value += 1;
    value = (value > 7)? 1:value;

A dropdown box only has a JavaScript object when Javascript control is enabled.


Rendering RadioButton, CheckBox and DropDownBox as a Javascript Control

By default, the RadioButton, CheckBox and DropDownBox controls are not Javascript controls (like the List control, for example) and as such, you can't call methods on the control to repopulate the choices shown in the control. You can however specify that these controls should be rendered as Javascript controls (which will then allow the choices in the control to be set using the control's .populate() method).

In this video, we show how a RadioButton control can be rendered as a Javascript control.

Download Component