How to select only one checkbox at a time in javascript example?

Today, We want to share with you only one checkbox selected at a time in javascript.In this post we will show you uncheck other checkboxes on selection of one checkbox javascript, hear for allow only one checkbox to be checked using javascript we will give you demo and example for implement.In this post, we will learn about Only one checkbox can be checked with an example.

how to select one checkbox from multiple checkboxes in javascript?

In following example use for you to do select at a time one.

Also Read This πŸ‘‰   JQuery Set Focus on First TextBox

Example 1: index.html

	<title>Select only one checkbox at time</title>
	<script src=""></script>
	<input value="1" name="shopitem" class="shopitem-list" type="checkbox">Laptop 
    <input value="2" name="shopitem" class="shopitem-list" type="checkbox">Mobile  
    <input value="3" name="shopitem" class="shopitem-list" type="checkbox">Iphone  
    <input value="4" name="shopitem" class="shopitem-list" type="checkbox">Computer  
    <input value="5" name="shopitem" class="shopitem-list" type="checkbox">LCD  
    <script type="text/javascript">
	    $('.shopitem-list').on('change', function() {
		    $('.shopitem-list').not(this).prop('checked', false);  

Using JavaScript


<input type="checkbox" id="1" value="laptop" onclick="getSelectItemThat(" /> Laptop 1
<input type="checkbox" id="2" value="mobile" onclick="getSelectItemThat(" /> Mobile 2
<input type="checkbox" id="3" value="computer" onclick="getSelectItemThat(" /> Computer 3
<input type="checkbox" id="4" value="lcd" onclick="getSelectItemThat(" /> LCD 4

JavaScript Code

function getSelectItemThat(id) {
    for (var i = 1;i <= 4; i++)
        document.getElementById(i).checked = false;
    document.getElementById(id).checked = true;

I hope you get an idea about how to select one checkbox from multiple checkboxes in javascript?.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.