1 // http://civicrm.org/licensing
3 function countSelectedCheckboxes(fldPrefix
, form
) {
5 for (i
= 0; i
< form
.elements
.length
; i
++) {
6 fpLen
= fldPrefix
.length
;
7 if (form
.elements
[i
].type
== 'checkbox' && form
.elements
[i
].name
.slice(0, fpLen
) == fldPrefix
&& form
.elements
[i
].checked
== true) {
15 * This function is used to check if any action is selected and also to check if any contacts are checked.
18 * @param fldPrefix - common string which precedes unique checkbox ID and identifies field as
19 * belonging to the resultset's checkbox collection
20 * @param form - name of form that checkboxes are part of
21 * Sample usage: onClick="javascript:checkPerformAction('chk_', myForm );"
24 function checkPerformAction(fldPrefix
, form
, taskButton
, selection
) {
28 // taskButton TRUE means we don't need to check the 'task' field - it's a button-driven task
29 if (taskButton
== 1) {
33 if (document
.forms
[form
].task
.selectedIndex
) {
34 //force user to select all search contacts, CRM-3711
35 if (document
.forms
[form
].task
.value
== 13 || document
.forms
[form
].task
.value
== 14) {
36 var toggleSelect
= document
.getElementsByName('toggleSelect');
37 if (toggleSelect
[0].checked
|| document
.forms
[form
].radio_ts
[0].checked
) {
41 alert("Please select all contacts for this action.\n\nTo use the entire set of search results, click the 'all records' radio button.");
50 // If user wants to perform action on ALL records and we have a task, return (no need to check further)
51 if (document
.forms
[form
].radio_ts
[0].checked
) {
55 cnt
= (selection
== 1) ? countSelections() : countSelectedCheckboxes(fldPrefix
, document
.forms
[form
]);
57 alert("Please select one or more contacts for this action.\n\nTo use the entire set of search results, click the 'all records' radio button.");
62 alert("Please select an action from the drop-down menu.");
68 * Function to enable task action select
70 function toggleTaskAction(status
) {
71 var radio_ts
= document
.getElementsByName('radio_ts');
73 radio_ts
[0].checked
= true;
75 if (radio_ts
[0].checked
|| radio_ts
[1].checked
) {
79 var formElements
= ['task', 'Go', 'Print'];
80 for (var i
= 0; i
< formElements
.length
; i
++) {
81 var element
= document
.getElementById(formElements
[i
]);
84 element
.disabled
= false;
87 element
.disabled
= true;