SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Strange Checkbox behaviour

    Hello,

    i am now banging my head for about 2 hours.

    Code:
    <label><input name="" type="checkbox" value="1" />yes</label>
    <label><input name="" type="checkbox" value="0" />no</label>
    if i click one check box, other one also getting selected auto. very annoying

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,228
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    Why do they both have the same name value?

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by afridy View Post
    if i click one check box, other one also getting selected auto. very annoying
    That code on its own doesn't create that behavior—not in my browser anyhow. Post an actual example that demonstrates the behavior:

    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    </head>
    <body>
    
    <label><input name="" type="checkbox" value="1" />yes</label>
    <label><input name="" type="checkbox" value="0" />no</label>
    
    </body>
    </html>

  4. #4
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    Why do they both have the same name value?
    ok , i just grabed the actual code from my script

    Code:
    <label>
    <input type="checkbox" name="checkbox" id="checkbox" value="a" />
    A
    </label>
    
    <label>
    <input type="checkbox" name="checkbox2" id="checkbox2" value="b" />
    B
    </label>

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Did you see my post? That code on its own is not likely to be the problem.

  6. #6
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    That code on its own doesn't create that behavior—not in my browser anyhow. Post an actual example that demonstrates the behavior:

    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    </head>
    <body>
    
    <label><input name="" type="checkbox" value="1" />yes</label>
    <label><input name="" type="checkbox" value="0" />no</label>
    
    </body>
    </html>
    hai ralph.
    can you kindly check this code in your browser?

    Code:
    <div id="alpha" style="border:1px solid black;">
    <label>
    <input type="checkbox" name="" id="checkbox" value="a" />
    A
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox2" value="b" />
    B
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox3" value="c"/>
    C
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox4" value="d"/>
    D
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox5" value="e"/>
    E
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox6" value="f"/>
    F
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox7" value="g"/>
    G
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox8" value="h"/>
    H
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox9" value="i"/>
    I
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox10" value="j"/>
    J
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox11" value="k"/>
    K
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox12" value="l"/>
    L
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox13" value="m"/>
    M
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox14" value="n"/>
    N
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox15" value="o"/>
    O
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox16" value="p"/>
    P
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox17" value="q"/>
    Q
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox18" value="r"/>
    R
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox19" value="s"/>
    S
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox20" value="t"/>
    T
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox21" value="u"/> 
    U
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox22" value="v"/>
    V
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox23" value="w"/>
    W
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox24" value="x"/>
    X
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox25" value="y"/> 
    Y
    </label>
    
    <label>
    <input type="checkbox" name="" id="checkbox26" value="z"/> 
    Z
    </label>
    </div>

  7. #7
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you folks for the valuable time you took to solve my issue.

    i just found the problem.
    the problem is just above the group of this check boxes, an un closed </lable> tag is what caused all the problem

    Code:
    <label><strong>COMBINATOR</strong>// << Lable not closed, this is what caused the problem
    <br />
    <br />
    Please select few charactors and click generate.<br />
    <span class="style1">*Selecting more than 7 characters is not recommended</span>
    <br />
    <br />
    <br />
    
    <div id="alpha" style="border:1px solid black;">
    <label>
    <input type="checkbox" name="A" id="A" />
    A</label>
    <label>
    <input type="checkbox" name="B" id="B" />
    B</label>
    <label>

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Hehe, thought it might be something like that.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •