Customizer's Guide > Working with XUI (XML-based User Interface) Dialog Boxes > Returning Values from Dialog Boxes
  
Returning Values from Dialog Boxes
Because the XUI document is updated when any values or states change in the control it defines, the value of the control can be obtained by evaluating the content of the XUI document. Based on the XUI DTD, each control type (textbox, checkbox, and so on) potentially stores its value in a different manner in the document.
For example, a <textbox> element stores its value as the content of its child <value> element. A <combobox> element stores it's value in its value attribute. Refer to XUI Element Reference (or the XUI DTD) for details on each control.
The following examples return the current values of different dialog box controls.
Example 4. Returning a value from a textbox control
The value of a <textbox> element is stored as the content of the child <value> element. The following example displays the value in a message window when the OK button is selected.

<?xml version="1.0" encoding="utf-8"?>
<!--ArborText, Inc., 1988-2003, v.4002-->
<!DOCTYPE window PUBLIC "-//Arbortext//DTD XUI XML 1.1//EN"
"xui.dtd">
<window orient="horizontal" align="center" modal="false" title="Value Test">
<label label="User ID"/>
<textbox id="userid">
<value></value>
</textbox>
<button label="OK" type="accept">
<script type="application/x-javascript" ev:event="domactivate">
var document = Application.event.target.ownerDocument;
var textnode = document.getElementById("userid").firstChild.firstChild;
if (textnode) {
Application.alert(textnode.nodeValue);
}
else {
Application.alert("[ EMPTY]");
}
var dialog = Application.event.view.window;
dialog.close();
</script>
</button>
</window>
Example 5. Returning a value from a combobox control
The value of a <combobox> is stored in its value attribute. The following example displays the value in a message window when the OK button is selected.

<?xml version="1.0" encoding="utf-8"?>
<!--ArborText, Inc., 1988-2003, v.4002-->
<!DOCTYPE window PUBLIC "-//Arbortext//DTD XUI XML 1.1//EN"
"xui.dtd">
<window orient="horizontal" align="center" modal="false" title="Value Test">
<label label="Choose a color"/>
<combobox id="color" value="Red" type="dropdownlist">
<listitem label="Red"/>
<listitem label="Orange"/>
<listitem label="Yellow"/>
<listitem label="Green"/>
<listitem label="Blue"/>
</combobox>
<button label="OK" type="accept">
<script type="application/x-javascript" ev:event="domactivate">
var document = Application.event.target.ownerDocument;
var value = document.getElementById("color").getAttribute("value");
Application.alert(value);
var dialog = Application.event.view.window;
dialog.close();
</script>
</button>
</window>
Example 6. Returning a value from a multiple-selection listbox control
You can select 1 or more values in a multiple-selection <listbox> control. The following example displays each selected value in a message window when the OK button is selected.

<?xml version="1.0" encoding="utf-8"?>
<!--ArborText, Inc., 1988-2003, v.4002-->
<!DOCTYPE window PUBLIC "-//Arbortext//DTD XUI XML 1.1//EN"
"xui.dtd">
<window orient="horizontal" modal="false" title="Value Test">
<label label="Choose Colors"/>
<listbox id="color" width="100" height="100" value="Red" type="multiple">
<listitem label="Red" selected="true"/>
<listitem label="Orange"/>
<listitem label="Yellow" selected="true"/>
<listitem label="Green"/>
<listitem label="Blue"/>
</listbox>
<button label="OK" type="accept">
<script type="application/x-javascript" ev:event="domactivate">
var document = Application.event.target.ownerDocument;
var listbox = document.getElementById("color");
var nodelist = listbox.getElementsByAttribute("selected", "true", 1);
for (var i = 0; i < nodelist.length; i++) {
Application.alert(nodelist.item(i).getAttribute("label"));
}
var dialog = Application.event.view.window;
dialog.close();
</script>
</button>
</window>
For more information on working with events, refer to the Events chapter in the Programmer's Reference.