input type=checkbox HTML元素

来源:百度文库 编辑:神马文学网 时间:2024/04/27 20:40:52
定义
创建复选框控件。
Creates a check box control.
注释
当 INPUT type=checkbox 元素被选中时,将向 FORM 提交 name/value 的一对值。INPUT type=checkbox 的默认值是 on。
INPUT type=checkbox 元素的 height 和 width 样式是从 Internet Explorer 5 版本起实现的。元素的大小设置基于作者提供的值,除非给定的大小低于所需的最小值。大小的尺寸计算如下:
若 height 或 width 大于 20 像素,复选框四周的间隙 (padding) 将设置为 4 像素,内部高度或宽度将设置为 8 像素。 若 height 或 width 小于 20 像素但大于 13 像素,复选框四周的间隙 (padding) 将等于所指定的 height 或 width 减去 13 的差的一半。例如,若指定复选框的 width 是 17,四周间隙将是: (17-13)/2 = 2 像素。 若 height 或 width 小于 12 像素,复选框四周的间隙 (padding) 将设置为 0, 且内部宽度将设置为作者指定的值。
此元素在 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:
If the height or width is greater than 20 pixels, the padding around the check box is set to 4 pixels, and the inner height or width is set to 8 pixels. If the height or width is less than 20 pixels but greater than 13 pixels, the padding around the check box is equal to one half the specified height or width minus 13. For example, if the specified width of the check box is 17, the equation would be: (17-13)/2. If the height or width is less than 12 pixels, the padding around the check box is set to 0 and the inner width is set to the value specified by the author.
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.
Uncheck     this check box for some free advice.

Or check     this check box for a message from our sponsors.


下面的例子就是用户单击复选框时调用的脚本。
This example implements the script when the user clicks either check box.
另见
input
相关教程和示例代码
HTML表单