References > " . "Element Reference"; $pagetitle="Radio"; $customsidebar = "elemref-sidebar.php"; include "header.php"; ?>

Radio

An element that can be turned on and off. Radio buttons are almost always grouped together in groups. Only one radio button within the same radiogroup may be selected at a time. The user can switch which radio button is turned on by selecting it with the mouse or keyboard. Other radio buttons in the same group are turned off. A label, specified with the label attribute may be added beside the radio button to indicate to the user as to its function.

More information about radio

The radio element implements the following interfaces:

nsIAccessibleProvider   nsIDOMXULSelectControlItemElement  

Attributes:

accesskey command crop disabled focused
label selected src value

Properties and Methods:

accessKey accessible crop disabled label
radioGroup selected value

Attributes:

Inherited from XUL Element:

align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
debug
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
observes
ordinal
orient
pack
persist
popup
position
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width

accesskey

Type: character

This should be set to a letter that is used as a shortcut key. This letter should be one of the characters that appears in the label text for the radio. This letter will typically be drawn underlined, although this behavior will be platform and theme specific. When the user presses ALT (or a similar key that varies on each platform) and the access key, the radio will be activated from anywhere in the window. Although the value is case insensitive, a letter with the case matching the accesskey attribute will used if both cases exist in the label.

command

Type: element id

Set to an id of a command element that is being observed by the element.

crop

Type: one of the values below

If the label of the radio is too small to fit in its given space, the text will be cropped on the side specified by the crop attribute. An ellipsis will be used in place of the cropped text. If the box direction is right to left (rtl), the cropping is reversed.

disabled

Type: boolean

Indicates whether the radio is disabled or not. If this attribute is set to true, the radio is disabled. This is usually drawn with the text in grey. If the radio is disabled, it does not respond to user actions. The element cannot be focused and the command event will not fire. The element will still respond to mouse events. To enable the radio, leave the attribute out entirely as opposed to setting the value to false.

focused

Type: boolean

This attribute is set to true if the radio element is focused.

label

Type: string

The label that will appear beside the radio. If this is left out, no text appears. The labels on radio buttons will wrap if there is not enough space.

selected

Type: boolean

This attribute is set to true if the radio button is selected by default. Leave this attribute out if it should not be set by default. To change the currently selected radio button, modify either the selectedIndex or selectedItem property of the radiogroup.

src

Type: image URL

The URL of the image to appear on the radio. If this attribute is left out, no image appears.

value

Type: string

You can associate a data value with each radio button.


Properties and Methods:

Inherited from XUL Element:

align
allowEvents
blur
boxObject
boxObject.element
boxObject.getLookAndFeelMetric
boxObject.height
boxObject.screenX
boxObject.screenY
boxObject.width
boxObject.x
boxObject.y
builder
className
click
collapsed
contextMenu
controllers
database
datasources
dir
doCommand
flex
focus
getElementsByAttribute
height
hidden
id
left
maxHeight
maxWidth
menu
minHeight
minWidth
observes
ordinal
orient
pack
persist
ref
resource
statusText
style
tooltip
tooltipText
top
width

Inherited from Element:

addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName

accessKey

Gets and sets the value of the accesskey attribute.

accessible

Type: nsIAccessible

Returns the accessibility object for the radio.

crop

Type: string

Gets and sets the value of the crop attribute.

disabled

Type: boolean

Gets and sets the value of the disabled attribute.

label

Type: string

Gets and sets the value of the label attribute.

radioGroup

Type: radiogroup element

Returns the enclosing radiogroup that the radio element is contained within, which may or may not be its direct parent.

selected

Type: boolean

Gets and sets the value of the selected attribute.

value

Type: string

Gets and sets the value of the value attribute.