Top community members
All Wiki Articles Create Wiki Article

In the past we had a dream,
to have place where we could share IT knowledge,
to ask questions without fear that someone will judge us.

Now we are a group of people who make this dream come true. ❤ 💻

If you think sharing knowledge and helping other is valuable.

join our community - Click here

HTML - check box example

0 contributions
14 points

Using HTML it is possible to create combo box field in few ways.

1. Combo box example

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<body>
  <form name="my-form">
    <label>My goals: </label><br />
    <input type="checkbox" name="friends" value="friends" /> Friends<br />
    <input type="checkbox" name="enjoy" value="enjoy" /> Enjoy<br />
    <input type="checkbox" name="learning" value="learning" /> Learning<br />
  </form>
</body>
</html>

2. Combo box with default selection example

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<body>
  <form name="my-form">
    <label>My goals: </label><br />
    <input type="checkbox" name="friends" value="friends" /> Friends<br />
    <input type="checkbox" name="enjoy" value="enjoy" checked /> Enjoy<br />
    <input type="checkbox" name="learning" value="learning" checked /> Learning<br />
  </form>
</body>
</html>

3. Combo box with disabled fields example

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<body>
  <form name="my-form">
    <label>My goals: </label><br />
    <input type="checkbox" name="friends" value="friends" /> Friends<br />
    <input type="checkbox" name="enjoy" value="enjoy" disabled /> Enjoy<br />
    <input type="checkbox" name="learning" value="learning" checked disabled /> Learning<br />
  </form>
</body>
</html>

4. Combo box inside label element example

In this approach we can change check box state by clicking on text too.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>
    
    label {
    	cursor: pointer;
    }
    
  </style>
</head>
<body>
  <form name="my-form">
    <div>My goals:</div>
    <label><input type="checkbox" name="friends" value="friends" /> Friends</label>
    <br />
    <label><input type="checkbox" name="enjoy" value="enjoy" /> Enjoy</label>
    <br />
    <label><input type="checkbox" name="learning" value="learning" /> Learning</label>
  </form>
</body>
</html>

Note: input element should be placed togater with text inside label element.

5. Combo box assigned with label example

In this approach we can change check box state by clicking on text too.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>
    
    label {
    	cursor: pointer;
    }
    
  </style>
</head>
<body>
  <form name="my-form">
    <div>My goals:</div>
    <input type="checkbox" name="friends" id="friends" value="friends" />
    <label for="friends">Friends</label>
    <br />
    <input type="checkbox" name="enjoy" id="enjoy" value="enjoy" />
    <label for="enjoy">Enjoy</label>
    <br />
    <input type="checkbox" name="learning" id="learning" value="learning" />
    <label for="learning">Learning</label>
  </form>
</body>
</html>

 

0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more