[Last Call] Learn how to a build a cloud-first strategyRegister Now


i can select the items of an checkboxlist1

Posted on 2011-10-29
Medium Priority
Last Modified: 2012-05-12
hi i have an checkboxlist1 and it's populate by the database, has +- 60 items, i want to create an javascript function to select the boxes or unselect or select some of it. i tryed this and did not worked. any help:

                                                             <a href="#" onclick="javascript:Select(true, 'CheckBoxList1')">Todos</a> | <a href="#" onclick="javascript:Select(false, 'CheckBoxList1')">Nenhum</a>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataTextField="ABREV"    DataValueField="NUMBER" ></asp:CheckBoxList>
<script type="text/javascript">
 function Select(Select, checkBoxListID){    
    for (var i = 0; i < 67; i++) {
        document.getElementsByTagName("ContentPlaceHolder1_" + checkBoxListID + "_0").checked = Select;

Open in new window

Question by:rafaelrgl
LVL 83

Expert Comment

ID: 37051400
in your browser, right click on your page and choose view source, post it here
LVL 38

Accepted Solution

Tom Beck earned 2000 total points
ID: 37051537
If you know the id of the container that holds the checkboxes (like ContentPlaceHolder1) then a script like this should work.
<script type="text/javascript">
 function Select(Select, checkBoxListID){ 
    var cph = document.getElementById("ContentPlaceholder1");
    var inputs = cph.getElementsByTagName("input"); 
    var inputId = "";      
    for (var i = 0; i < inputs.length; i++) {
        inputId = inputs[i].id;
        if(inputId.indexOf(checkBoxListID) != -1) {
            inputs[i].checked = Select;

Open in new window


Author Closing Comment

ID: 37051566
perfect. thanks

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month17 days, 15 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question