Hi, I'm trying to find a way to create a CheckListBox for ASP classic. I've been using ASP.Net before and this control is already included. I'm kind of struggling with ASP classic but it's part of work so :'( ... Anyways if there is no definite control for CheckListBox for asp classic can you suggest a way where I can get an array of CheckBox in a container that scrolls vertically..
Thanks in advance

You just need to do something like this:

Create all your checkboxes, and order them however you wish since it doesn't matter.

They all need to have the same name, but different ID's.

By having the same name, you can tap into the group.

Then you need to use javascript to loop through all those elements within that group. WIthin that loop, you will check to see if the current element is checked. If it is, uncheck it.

After the loop is over, check the clicked element.

If you have a large group, you need to log the id and compare the id to every element, and uncheck those that are not corresponding with that id.

Javascript code is below. For learnign purposes, the name of the group for your checkboxes will be : chkBoxGroup

<script type="text/javascript">
<!--//

function chk(id)
{
  var chkID;

  for(var i = 0; i < document.all.chkBoxGroup.length; i++)
  {
    chkID = document.all.chkBoxGroup[i];

    if (chkID && chkID.checked == true) { chkID.checked = false; }
  }

  docuement.getElementById(id).checked = true;
}

-->
</script>

<input type="checkbox" id="chk1" name="chkBoxGroup" onclick="chk(this)" onchange="chk(this)" value="" />
This article has been dead for over six months. Start a new discussion instead.