none
Checkbox and Select All RRS feed

  • Question

  • I have a SharePoint List Column that is a choice field Checkbox. I have entered all my choices but want to have a Select All choice. How would I go about checking all the boxes when the Select All is checked?
    Tuesday, February 2, 2010 6:54 PM

Answers

  • Hello,
             Either you can create custom field type , which supports this functionaliy at new form, edit form and view form.

            So though javascript , with ascessing all elements having ms-RadioText css class name.
            
           By default all items in choice column has class= ms-RadioText . so checking title of current element selected is "SelectAll" then select all elements which has ms-RaidoText class as css.

             for reference.

                    $(document).ready(function()
         {
    $(".ms-RadioText").click(function()
    {
       if(this.checked == true)
       {
       if(this.title == 'SelectAll')
       {
       alert(this.title);
                                    ///  you can create logic for selecting all items 
       }
       }
    });
    });



           





     
    • Marked as answer by Chengyi Wu Friday, February 12, 2010 2:07 AM
    Tuesday, February 2, 2010 7:55 PM
  • The easiest solution to create list with choices and add multi lookup field to it.
    Second make choice field SPMultiChoiceField and program your own edit form, with select all functionality.
    L. M.
    • Marked as answer by Chengyi Wu Friday, February 12, 2010 2:07 AM
    Tuesday, February 9, 2010 8:06 PM

All replies

  • you can achieve this by client scripting. just add Content Editor Web Part and put some HTML elements and javascript inside, walking through checkboxes and doing the job. JQuery could be used as well.
    Tuesday, February 2, 2010 7:09 PM
  • Hello,
             Either you can create custom field type , which supports this functionaliy at new form, edit form and view form.

            So though javascript , with ascessing all elements having ms-RadioText css class name.
            
           By default all items in choice column has class= ms-RadioText . so checking title of current element selected is "SelectAll" then select all elements which has ms-RaidoText class as css.

             for reference.

                    $(document).ready(function()
         {
    $(".ms-RadioText").click(function()
    {
       if(this.checked == true)
       {
       if(this.title == 'SelectAll')
       {
       alert(this.title);
                                    ///  you can create logic for selecting all items 
       }
       }
    });
    });



           





     
    • Marked as answer by Chengyi Wu Friday, February 12, 2010 2:07 AM
    Tuesday, February 2, 2010 7:55 PM
  • I was hoping to add Javascript directly to the page (NewForm.aspx). I have a SharePoint Checkbox with the following data:
    <SharePoint:FormField runat="server" id="ff6{$Pos}" controlmode="New" fieldname="Select_x0020_All_x0020_Test" __designer:bind="{ddwrt:DataBind('i',concat('ff6',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Select_x0020_All_x0020_Test')}" />

    The values are Select All, Select One, Select Two, Select Three

    How do I get this Checkbox to fire off the Javascript to check all the boxes if the choice is Select All? It doesn't seem to want to take an OnClick event.
    Tuesday, February 9, 2010 3:34 PM
  • I think I'm getting closer. I added the Content Editor Web Part and am now trying to walk through the checkbox:

    <script type="text/javascript">
    function SelectAll(CheckBoxControl)
    {
    if (CheckBoxControl.checked == true)
    {
    var i;
    for (i=0; i < document.forms[0].elements.length; i++)
    {
    if ((document.forms[0].elements[i].type == 'checkbox') &&
    (document.forms[0].elements[i].name.indexOf('Select All Test) > -1))
    {
    document.forms[0].elements[i].checked = true;
    }
    }
    }
    else
    {
    var i;
    for (i=0; i < document.forms[0].elements.length; i++)
    {
    if ((document.forms[0].elements[i].type == 'checkbox') &&
    (document.forms[0].elements[i].name.indexOf('Select All Test') > -1))
    {
    document.forms[0].elements[i].checked = false;
    }
    }
    }
    }
    getField('select','Select All Test').onchange = function() {SelectAll()};
    </script>


    So far this does not work. I know how to walk through and asp checkbox but this formfield is different.

    • Edited by neddyflanders Tuesday, February 9, 2010 6:58 PM duplicated code
    Tuesday, February 9, 2010 6:56 PM
  • The easiest solution to create list with choices and add multi lookup field to it.
    Second make choice field SPMultiChoiceField and program your own edit form, with select all functionality.
    L. M.
    • Marked as answer by Chengyi Wu Friday, February 12, 2010 2:07 AM
    Tuesday, February 9, 2010 8:06 PM