JavaScript

$gvs Function

Syntax

$gvs(element)

Arguments

elementelement objectstringarray

A string with the ID or NAME of the element, a pointer to an HTML element, or an array of either of the previous.

Returns

Valuearray

Returns the value of the specified element(s).

Description

The $gvs() function gets the value from a single 'conceptual' element.

Discussion

A 'conceptual' control in the HTML can be represented by multiple physical elements. For example, a radio button with the choices 'Green', 'Red' and 'Blue' can be thought of as a single 'conceptual' control, but the HTML will contain three physical elements, one for each of the options.

If the control passed in has multiple values, as with a SELECT set to allow multiple selections, or a checkbox group, the function will return an array of values. Otherwise it will return a string of the value.

You can also use $gvs() against elements that are not form controls - the function will return the innerHTML property of the element.

Example

/*Assume that the HTML contains this markup for a radio button group
<input type="radio" name="FavoriteColor" value="Red"  id="radio1"  /><label for="radio1">Red</label>
<input type="radio" name="FavoriteColor" value="Blue"  id="radio2"  /><label for="radio2">Blue</label>
<input type="radio" name="FavoriteColor" value="Green"  id="radio3"  /><label for="radio3">Green</label>
*/
 
/*Get the selected value in the 'FavoriteColor' radio button control*/
alert($gvs('FavoriteColor'));
 
 
/*Assume that the HTML contains a SELECT control that allows multiple selections.
Red and Green are currently selected
<select id="FavoriteColorSelect" size="5"  multiple="multiple">
    <option selected="selected">Red</option>
    <option>Blue</option>
    <option selected="selected">Green</option>
</select>
*/
 
/*Get the current selections in the SELECT control into an array*/
arr = $gvs('FavoriteColorSelect');
 
/*Assume that the HTML contains a SPAN with an ID of 'span1'
Display the innerHTML property of the span.*/
?alert($gvs('span1'));
Use {dialog.object}.getPointer() to get the DOM element for a control.

See Also