创建复选框控件。
Creates a check box control.
当 INPUT type=checkbox 元素被选中时,将向 FORM 提交 name/value 的一对值。INPUT type=checkbox 的默认值是 on。
INPUT type=checkbox 元素的 height 和 width 样式是从 Internet Explorer 5 版本起实现的。元素的大小设置基于作者提供的值,除非给定的大小低于所需的最小值。大小的尺寸计算如下:
此元素在 Internet Explorer 3.0 及以上版本的 HTML 和脚本中可用。
此元素是一个内嵌元素。
此元素不需要关闭标签。
When an INPUT type=checkbox element is selected, a name/value pair is submitted with the FORM. The default value of INPUT type=checkbox is on.
The height and width styles are exposed to the INPUT type=checkbox element as of Internet Explorer 5. The size of the element is set based on the values provided by the author, except when a given size is below a particular minimum. The size is calculated as follows:
This element is available in HTML and script as of Internet Explorer 3.0.
This element is an inline element.
This element does not require a closing tag.
下面的例子使用 INPUT type=checkbox 元素创建了两个带有解释文本的复选框。onclick 事件将调用两个脚本函数。第一个复选框默认选中。
This example uses the INPUT type=checkbox element to create two check boxes with explanatory text. The onclick events call two script functions. The first check box is checked.
<INPUT TYPE=checkbox CHECKED ID=chk1 onclick="choosebox1()">Uncheck
this check box for some free advice.
<P><INPUT TYPE=checkbox ID=chk2 onclick="choosebox2()">Or check
this check box for a message from our sponsors.
<P ID=SampText>
下面的例子就是用户单击复选框时调用的脚本。
This example implements the script when the user clicks either check box.
<SCRIPT>
function choosebox1(){
alert("Never play leapfrog with a unicorn!")
}
function choosebox2(){
SampText.insertAdjacentHTML("AfterBegin","Buy WonderWidgets! ");
}
</SCRIPT>