Alvaro February 2016

only one checkbox selected at a time in jquery

I am working on a popup window for a website that makes you choose between some options before logging into it. The deal is that I am trying to apply with jquery, the function "one checkbox selected at a time".

I tried a lot of different possibilities but for some reason it doesn't work on my code.

Here is my code:

    <body>
    <header>
        <div class="titulo">
            <img src="GET_your.png" alt="">
        </div>
    </header>
    <div class="container">
        <article class="mf">
            <div><img src="Indetify.png" alt="" style="padding-    bottom:40px;"></div>
            <div id="firstblock">
                <div class="male">
                    <img src="Sim_Boy.png" alt=""><br>
                    <input type="checkbox" id="chkBox100"      onClick="toggle(this);" class="input_class_checkbox"><br>
                    <img src="Male.png" alt="">
                </div>
                <div class="female">
                    <img src="Sim_girl.png" alt=""><br>
                    <input type="checkbox" id="chkBox121"         onClick="toggle(this);" class="input_class_checkbox"><br>
                    <img src="Female.png" alt="" style="padding-   top:4px;">
                </div>
            </div>
        </article>
        <aside class="all">
            <div style="margin-left:60px;"><img src="like.png" alt="" style="padding-bottom:40px;"></div>
            <div>
                <div class="all_one">
                    <img src="Sim_Boy.png" alt=""><br>

                    <input type="checkbox" class="input_class_checkbox"><br>

                    <img src="Male.png" alt="">
                </div>
                <div class="all_one">
                    <im        

Answers


KjetilNordin February 2016

Use radio buttons instead. Group the selected groups by "name":

  <input type="radio" name="example" value="male"> Male<br>
  <input type="radio" name="example" value="female"> Female<br>
  <input type="radio" name="example" value="other"> Other

  <input type="radio" name="example2" value="plane"> Plane<br>
  <input type="radio" name="example2" value="car"> Car<br>
  <input type="radio" name="example2" value="bus"> Bus

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

PS: radio buttons can be styled to look like checkboxes, if that is your preferred layout...

Post Status

Asked in February 2016
Viewed 3,456 times
Voted 4
Answered 1 times

Search




Leave an answer