Exampler.org SAS PYTHON HTML
HTML Home
HTML Table
HTML Form
HTML Button
HTML Checkbox
HTML Select
HTML Contact Form

HTML Checkbox Input;

What is it?

Syntax:

  • Checkbox: <input type='checkbox' id='checkbox1' name="color" checked>


 Basic Checkbox Example :



<form action='transmitmydata.php' method='post' >

     Red <input type='checkbox' id='red' name='color' checked>
     Blue <input type='checkbox' id='blue' name='color' checked>
     Green <input type='checkbox' id='green' name='color' checked>
     <input type='button' value='Submit'>

</form>





What's happening in the script above?

  • The above form has 3 checkboxes and 1 submit button
  • Each checkbox has their own id value which is really useful when using JavaScript. JavaScript will allow you access each checkbox using the following command.
  • <script> x = document.getElementById("red").value <script>
  • Also in this example, all the checkboxes are by default "checked" you could just as easily remove that word, and the checkboxes will default to empty.


Example Output:

Red Blue Green






See also; HTML Form

See also; HTML Buttons

See also; HTML Table




Connect via LinkedIn

Kevin Regan

Have an article, idea, found a typo, want to contribute? Shoot me an email Here