mozilla

radiogroup

A group of radio buttons. Only one radio button inside the group can be selected at a time. The radio buttons may either direct children of the radiogroup or descendants. Place the radiogroup inside a groupbox if you would like a border or caption for the group. The radiogroup defaults to vertical orientation.

More information is available in the XUL tutorial.

Attributes
disabled, focused, preference, tabindex, value
Properties
accessibleType, disabled, focusedItem, itemCount, selectedIndex, selectedItem, tabIndex, value
Methods
appendItem, checkAdjacentElement, getIndexOfItem, getItemAtIndex, insertItemAt, removeItemAt

Examples

Image:XUL_ref_radios.png
<radiogroup>
  <radio id="orange" label="Red"/>
  <radio id="violet" label="Green" selected="true"/>
  <radio id="yellow" label="Blue"/>
</radiogroup>

Attributes

disabled
Type: boolean
Indicates whether the element is disabled or not. If this element is set to true the element is disabled. Disabled elements are usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused, and the command event will not fire.
Visible controls have a disabled property which, except for menus and menuitems, is normally preferred to use of the attribute, as it may need to update additional state.
focused
Type: boolean
This attribute is true if the element is focused.
preference
Type: id
Connects the element to a corresponding preference. This attribute only has any effect when used inside a prefwindow. More information is available in the Preferences System article.
tabindex
Type: integer
The tab order of the element. The tab order is the order in which the focus is moved when the user presses the "tab" key. Elements with a higher tabindex are later in the tab sequence.
value
Type: string
The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use. Be aware, however, that some elements, such as textbox will display the value visually, so in order to merely associate data with an element, you could 1) Use another attribute like "value2" or "data-myAtt" (as in the HTML5 draft), as XUL does not require validation (less future-proof); 2) Use setAttributeNS() to put custom attributes in a non-XUL namespace (serializable and future-proof); 3) Use setUserData() (future-proof and clean, but not easily serializable). For user editable menulist elements, the contents, as visible to the user, are read and set using the Menulist.value syntax. For those elements, setAttribute("value", myValue) and getAttribute("value") do not access or affect the contents displayed to the user.

 

Properties

accessibleType
Type: integer
A value indicating the type of accessibility object for the element.
disabled
Type: boolean
Gets and sets the value of the disabled attribute.
focusedItem
Type: radio element
Holds the currently focused item in the radiogroup, which may or may not be the same as the selected item. You can change the focused item by setting this property.
itemCount
Type: integer
Read only property holding the number of child items.
selectedIndex
Type: integer
Returns the index of the currently selected item. You may select an item by assigning its index to this property. By assigning -1 to this property, all items will be deselected. Returns -1 if no items are selected
selectedItem
Type: element
Holds the currently selected item. If no item is currently selected, this value will be null. You can select an item by setting this value. A select event will be sent to the controlling container (i.e. the listbox, richlistbox, radiogroup, etc., not the list item that was selected) when it is changed either via this property, the selectedIndex property, or changed by the user.
tabIndex
Type: integer
Gets and sets the value of the tabindex attribute.
value
Type: string
Gets and sets the value of the value attribute. For textbox and user editable menulist elements, the contents, as visible to the user, are read and set using the Textbox.value and Menulist.value syntax.

 

Methods

Inherited Methods
addEventListener(), appendChild(), blur, click, cloneNode(), compareDocumentPosition, dispatchEvent(), doCommand, focus, getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getBoundingClientRect(), getClientRects(), getElementsByAttribute, getElementsByAttributeNS, getElementsByClassName(), getElementsByTagName(), getElementsByTagNameNS(), getFeature(), getUserData, hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isDefaultNamespace(), isEqualNode, isSameNode, isSupported(), lookupNamespaceURI, lookupPrefix, normalize(), querySelector(), querySelectorAll(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS(), setUserData

appendItem( label, value )
Return type: element
Creates a new item and adds it to the end of the existing list of items. You may optionally set a value. The function returns the newly created element.
checkAdjacentElement( dir )
Return type: no return value
Deselects the currently selected radio button in the group and selects the one adjacent to it. If the argument <var>dir</var> is true, the next radio button is selected. If it is false, the previous radio button is selected.
getIndexOfItem( item )
Return type: integer
Returns the zero-based position of the specified item. Items are numbered starting at the first item displayed in the list.
getItemAtIndex( index )
Return type: element
Returns the element that is at the specified index.
insertItemAt( index, label, value )
Return type: element
This method creates a new item and inserts it at the specified position. You may optionally set a value. The new item element is returned.
removeItemAt( index )
Return type: element
Removes the child item in the element at the specified index. The method returns the removed item.

Interfaces
nsIAccessibleProvider, nsIDOMXULSelectControlElement

Document Tags and Contributors

Contributors to this page: Sheppy, trevorh, Enn, Ptak82, Mgjbot, Dria, Pmash
Last updated by: Sheppy,