<style>
.chb
{
width: 30px;
}
</style>
<script type="text/javascript" src="jquery-1.5.2.js"></script>
<script>
$(".chb").each(function() {
$(this).change(function() {
$(".chb").attr('checked',false);
$(this).attr('checked',true);
});
});
</script>
<form action="demo_form.asp">
<input type="checkbox" name="vehicle" value="Bike" class ="chb"> I have a bike<br>
<input type="checkbox" name="vehicle" value="Car" checked="checked" class="chb"> I have a car <br>
</form>
The above coding contains two check boxes with radio button functionality. This works fine. But how to do this with javascript without using the jquery. How to achieve this.
If you concern only about functionality and you have lot of checkboxes this is an easy solution.
Now add
onclickevents to your all checkboxes as below.