Select one checkbox and disable others

 


Select one checkbox and disable others using jquery

I have group of checkbox buttons, if I click and check one I want other check boxes to be set to disable.
Also if I click to the same and uncheck I want all of them to be enabled. 






Our Best Popular Projects & Posts

Post Link
School Management System With Full Source Code In php click here
ecommerce project in php click here
simple login and registration form in php click here
Synopsis for online rooms booking project based on PHP click here
add multiple images in codeigniter click here
beginners project in php with source code click here
dynamic country state dropdown in codeigniter click here
how to generate pdf using dompdf in codeigniter click here
add 1 day to current date in php click here
how to check website/blog responsive or not? click here
employee attendance management system project in php with source code click here
Select one checkbox and disable others click here
printing div content with css applied click here
best restaurants management system in php click here
Preview an image before it is uploaded using jquery click here
text editor in jquery click here
data table with export button in html click here
add multiple images in codeigniter click here
codeigniter some steps to install on Your server click here
ajax in php/codeigniter click here
Create Simple API CRUD with PHP and MySQL click here
How to integrate bootstrap theme in codeigniter click here
how to prepare for interview click here
Convert a date format in PHP click here
how to export html table to excel in jquery click here
how to create duplicate google peg using ajax click here
how to make dropdown searchable in html using jquery click here
how to find retirement date in php click here
online food order system in php with source code click here
school management project admin panel in php click here



<!DOCTYPE html>

<html>

<head>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title></title>

  

   <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>

   


</head>


<body>


<div class="container"><div class="row"><br>

<div class ="col-md-12"><form id="user_form"> 



         <input type="checkbox" class="Present 1" name="attedence[]" id ="1"  value="P" required>

          <input type="checkbox" class="Present 1" name="attedence[]" id ="1" value="A" required>

        <input type="checkbox" class="Present 1" name="attedence[]" id ="1"  value="H" required>

        <input type="checkbox" class="Present 1" name="attedence[]" id ="1"  value="F" required>


<br>

       

       <input type="checkbox" class="Present 2" name="attedence[]" id ="2"  value="P" required>

          <input type="checkbox" class="Present 2" name="attedence[]" id ="2" value="A" required>

        <input type="checkbox" class="Present 2" name="attedence[]" id ="2"  value="H" required>

        <input type="checkbox" class="Present 2" name="attedence[]" id ="2"  value="F" required>



 </tbody>

  </table></form></div></div></div>

</body>

</html>

<script type="text/javascript">

  $('input:checkbox').click(function(){

   var id = ($(this).attr('id'));

   // alert(id)

    var $inputs = $("#id")

        if($(this).is(':checked')){

            // $("."+id).prop('disabled', true); // <-- disable all but checked one

             $("."+id).not(this).prop('disabled',true);

        }else{

           // $inputs.prop('disabled',false); // <--

           $("."+id).prop('disabled', false);

        }

    })

</script>

0 Comments