Horje
How to Specify the Value of a Checkbox using Attribute ?

To specify the value of a checkbox using an attribute in HTML, you utilize the “value” attribute within the <input> tag. This attribute allows you to assign a specific value to the checkbox, which is sent to the server if the checkbox is checked when the form is submitted.

Syntax

<input type="checkbox" name="checkbox_name" value="checkbox_value">

The table below illustrates the attributes alongside their descriptions.

Attribute Description
type="checkbox" Specifies that the input element is a checkbox.
name="checkbox_name" Identifies the checkbox when the form is submitted.
value="checkbox_value" Assign a specific value to the checkbox. This value is sent to the server if the checkbox is checked.

Features

  • Assigning Values: The “value” attribute assigns a specific value to the checkbox, which is submitted to the server if the checkbox is checked.
  • Form Submission: When the form containing the checkbox is submitted, the checkbox value is included in the form data sent to the server.
  • Identifying Checkboxes: The “name” attribute identifies the checkbox within the form, allowing you to distinguish it from other form elements.
  • Multiple Checkboxes: You can have multiple checkboxes with the same name but different values, allowing users to select multiple options.
  • Conditional Processing: Server-side scripts can process form submissions based on the values of checkboxes, enabling conditional logic and actions.



Reffered: https://www.geeksforgeeks.org


HTML

Related
How to specify the encoding type of form data in HTML ? How to specify the encoding type of form data in HTML ?
What is the use of cols Attribute in &lt;textarea&gt; Tags ? What is the use of cols Attribute in &lt;textarea&gt; Tags ?
How to Specify the Height of a line in HTML ? How to Specify the Height of a line in HTML ?
What is the use of size Attribute in &lt;select&gt; Tags ? What is the use of size Attribute in &lt;select&gt; Tags ?
What is the use of ismap Attribute in &lt;img&gt; Tags ? What is the use of ismap Attribute in &lt;img&gt; Tags ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
13