Kuttan Sujith
Kuttan Sujith

Reputation: 7979

How to check a checkbox

http://www.w3schools.com/html/tryit.asp?filename=tryhtml_checkbox

Try it with the input below:

<html>
<body>

<form action="">
<input type="checkbox" name="vehicle" value="Bike" checked="false" /> I have a bike<br />
<input type="checkbox" name="vehicle" value="Car" /> I have a car 
</form>

</body>
</html>

I have a bike has checked="false" still that is checked why?

Upvotes: 1

Views: 647

Answers (2)

GomathyP
GomathyP

Reputation: 147

u have used checked=false. This is not the right method to uncheck the checkbox. use as follows.

<form action="">
<input type="checkbox" name="vehicle" value="Bike" checked="checked">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car" checked="">I have a car 
</form>

checked="checked" will check the checkbox. checked="" will uncheck it. you can also use checked instead of checked="checked".

Upvotes: 0

rid
rid

Reputation: 63540

"false" has no meaning. The HTML rendering engine looks to see if the "checked" attribute is present, regardless of what value it contains. If it's present (whatever the value), then the checkbox will be checked. If it's not present, then it won't be checked.

Upvotes: 4

Related Questions