This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Select All Feature for Checkboxes


  1. tania
    Member

    Is there a way to have an option in the Checkbox list to "select all" - and all options are checked automatically?

    Thanks!

    Posted 14 years ago #
  2. redityo

    I think it can be done by adding a javascript to your "includes/view-functions.php" file. To do so, you need add 1 check box option to trigger "select all" function.
    Let say your "check box" id's is 1 and your "select all" option id's is "element_1_4", then edit "includes/view-functions.php" file and go to around line 1832 for this code :

    <script type="text/javascript" src="js/view.js"></script>

    put these code exactly bellow that line

    <script type="text/javascript" src="js/jquery/jquery-core.js"></script>
    <script type="text/javascript">
    	var flag = 0 ;
    	$(document).ready(function() {
    		$('#form_6 #element_1_4').click(function() {
    			if (flag == 0) {
    				$('#li_1 :checkbox').attr('checked',true);
    				flag = 1;
    			} else {
    				$('#li_1 :checkbox').attr('checked',false);
    				flag = 0;
    			}
    		});
    	});
    </script>

    After that you need to adjust those id's to get the script working properly in your form.


    MachForm Support

    Posted 14 years ago #
  3. tania
    Member

    This worked great. However, the option id was hard to identify. Is there an easy way to know what number it is? For example, it was not the 4th option (because I had deleted options and added others).

    Posted 14 years ago #
  4. redityo

    You can see form HTML source code to see the option id, but if you're using Firefox maybe you can try to use "Firebug" add-ons from there.


    MachForm Support

    Posted 14 years ago #
  5. tania
    Member

    Can I modify this by having a checkbox such as "select all morning sessions" and it will check certain element checkboxes only (and not all)?

    Posted 14 years ago #

RSS feed for this topic

Reply