XUL Programmer's Reference Manual

<checkbox>

Attributes Common Children
value * * *
accesskey  
disabled  
oncommand  
id  
class  
checked  
crop  
imgalign  
src  

The <checkbox> element provides a special button widget that the user can check and uncheck. Unlike radio buttons, checkboxes are not grouped with one another in any particular way, so their checking and unchecking is not linked or mutually exclusive.

 
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 

<window id="checkboxes" 
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <box style="background-color: lightblue;" orient="vertical">
	<checkbox value="James Joyce" />
	<checkbox value="Joseph Conrad" />
	<checkbox value="William Faulkner" />
  </box>
</window>

 
value
Description
The value attribute specifies the name displayed for the checkbox item.
Syntax
<checkbox value="string" />
Example
<checkboxvalue="Honda"/>
<checkbox value="Isuzu" />
Notes
None.
checked
Description
When checked is set to "true", the checkbox is pre-selected.
 
Syntax
checked="[true | false]"
Example
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 

<window id="checkboxes" 
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <box style="background-color: lightblue;" orient="vertical">
	<checkbox value="James Joyce" />
	<checkbox value="Joseph Conrad" checked="true" />
	<checkbox value="William Faulkner" />
  </box>
</window>
Notes
None.
 
oncommand
Description
oncommand is an optional event listener attribute for the checkbox.
Syntax
<checkbox id="string" value="string" oncommand="event handler code" />
Example
<checkbox id="whichCar" value="Honda" oncommand="doHondaPrep()" />
Notes
None.

 

 

crop
Description
crop is an optional attribute which part of the checkbox's text, if any, is clipped when the parent container doesn't provide enough space.
Syntax
<checkbox crop="left | right | none" />
Example
<checkbox value="Long Name For This Checkbox"
crop="left" />
Notes
None.

 

 

imgalign
Description
imgalign is an optional attribute for aligning the imported graphic with the checkbox.
Syntax
<checkbox src="graphic" 
imgalign="
  absbottom |
  absmiddle |
  baseline  |
  bottom    |
  left      |
  middle    |
  right     |
  texttop   |
  top" />
Example
<checkbox src="newbutton.gif" imgalign="absmiddle" />
Notes
None.

 

 

src
Description
src is an optional attribute for specifying graphic images to use in place of the the actual checkbox.
Syntax
<checkbox src="chrome or regular url to graphic" />
Example
<checkbox src="chrome://global/newbox.gif" />
Notes
None.

 

 


 
 
Last updated: 3/21/00 Ian Oeschger