Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how can I only allow a user to select only one checkbox (bootstrap checkbox)?

I added bootstrap checkboxes in my code, but the user should be able to select only one checkbox, the others get unchecked automatically. But I m not able to do that, can someone tell what should I add in my code please
Here is the screenshot of the result

<div class="form-check form-switch" style="display: flex;">
                               
     <label class="form-check-label" for="uo1">UO1</label><br>
     <input class="form-check-input" type="checkbox" name="uo1" id="uo1" value="0" />
     
      <div id="uo1div" style="display:none">
       <BR> TJM = 225 €
      </div>
                                 
   <script type="text/javascript">
      $('#uo1').change(function() {
           $('#uo1div').toggle();
      });
   </script>

</div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You want a radio type input, not check boxes. Each input gets a unique id and value, but the same name to put it in a "radio group."
See https://www.w3schools.com/html/html_form_input_types.asp

<input class="form-check-input" type="radio" name="uo" id="uo0" value="0" />
<input class="form-check-input" type="radio" name="uo" id="uo1" value="1" />
<input class="form-check-input" type="radio" name="uo" id="uo2" value="2" />
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading