We help IT Professionals succeed at work.
Get Started

HTML list with checkboxes

VapiSoft asked
Last Modified: 2012-05-09
I asked the experts how to create a list with checkboxes.
I recived the attached code from remorina, which is very good.
The only problem I have with it, is that when I click on the second line, the first line stays selected. I want that only the selected line will show as selected.
<title>Scrolling Checkboxes</title>  
<style type="text/css">  
    body {font:normal 12px Arial, Helvetica, Serif;}  
    .boxlist {overflow:auto;width:130px;height:75px;border:1px solid #336699;padding:0px;white-space:nowrap;overflow-x:hidden;}  
    .boxlist input {margin:0 0px 0 0;height:14px;width:17px;} 
    .selectelement {background:#fff;cursor:pointer;} 
    .selectedelement {background:#c0c0c0;cursor:pointer;} 
<script type="text/javascript"> 
        function selectThis(el,cls) { 
            if (el.className=="selectelement")  
<script type="text/javascript"> 
function abc(obj,num) 
<div class="boxlist" id="abc" style="width:100%">  
<div class="selectelement" onclick="selectThis(this, 'chk1');"><input type="checkbox" id="chk1" name="wow[0]" onclick="abc(this,5)">PHP</div> 
<div class="selectelement" onclick="selectThis(this, 'chk2');"><input id="chk2" type="checkbox" name="wow[1]">LINUX</div> 
<div class="selectelement" onclick="selectThis(this, 'chk3');"><input id="chk3" type="checkbox" name="wow[]">APACHE</div>  
<div class="selectelement" onclick="selectThis(this, 'chk4');"><input id="chk4" type="checkbox" name="wow[]">MYSQL</div>  
<div class="selectelement" onclick="selectThis(this, 'chk5');"><input id="chk5" type="checkbox" name="wow[]">SQLITE</div>  
<div class="selectelement" onclick="selectThis(this, 'chk6');"><input id="chk6" type="checkbox" name="wow[]">A Much Longer Line</div> 

Open in new window

Watch Question
Top Expert 2010
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE