From be2197b4ae059e190f111306485b962957e20153 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Sun, 13 Nov 2005 08:06:14 +0000 Subject: [PATCH] - removed deprecated function setCheckboxesRange() - rewrote setCheckboxes() --- ChangeLog | 3 +++ libraries/functions.js | 61 +++++++++--------------------------------- 2 files changed, 15 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7201546c5..40496c7e5 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ $Source$ 2005-11-13 Sebastian Mendel * db_details_structure.php: wrong js function call + * libraries/functions.js + - removed deprecated function setCheckboxesRange() + - rewrote setCheckboxes() 2005-11-11 Marc Delisle * lang/bulgarian: Update, thanks to Stanislav Yordanov - stanprog. diff --git a/libraries/functions.js b/libraries/functions.js index 66b1470e8..9d5d6582e 100644 --- a/libraries/functions.js +++ b/libraries/functions.js @@ -853,61 +853,24 @@ function setVerticalPointer(theRow, theColNum, theAction, theDefaultColor1, theD } // end of the 'setVerticalPointer()' function /** - * Checks/unchecks all tables - * - * @param string the form name - * @param boolean whether to check or to uncheck the element + * Checks/unchecks all checkbox in given conainer (f.e. a form, fieldset or div) * + * @param string container_id the container id + * @param boolean state new value for checkbox (true or false) * @return boolean always true */ -function setCheckboxes(the_form, do_check) -{ - var elts = (typeof(document.forms[the_form].elements['selected_db[]']) != 'undefined') - ? document.forms[the_form].elements['selected_db[]'] - : (typeof(document.forms[the_form].elements['selected_tbl[]']) != 'undefined') - ? document.forms[the_form].elements['selected_tbl[]'] - : document.forms[the_form].elements['selected_fld[]']; - var elts_cnt = (typeof(elts.length) != 'undefined') - ? elts.length - : 0; +function setCheckboxes( container_id, state ) { + var checkboxes = document.getElementById(container_id).getElementsByTagName('input'); - if (elts_cnt) { - for (var i = 0; i < elts_cnt; i++) { - elts[i].checked = do_check; - } // end for - } else { - elts.checked = do_check; - } // end if... else + for ( var i = 0; i < checkboxes.length; i++ ) { + if ( checkboxes[i].type == 'checkbox' ) { + checkboxes[i].checked = state; + } + } - return true; + return true; } // end of the 'setCheckboxes()' function -/** - * Checks/unchecks all rows - * - * @param string the form name - * @param boolean whether to check or to uncheck the element - * @param string basename of the element - * @param integer min element count - * @param integer max element count - * - * @return boolean always true - */ -// modified 2004-05-08 by Michael Keck -// - set the other checkboxes (if available) too -function setCheckboxesRange(the_form, do_check, basename, min, max) -{ - for (var i = min; i < max; i++) { - if (typeof(document.forms[the_form].elements[basename + i]) != 'undefined') { - document.forms[the_form].elements[basename + i].checked = do_check; - } - if (typeof(document.forms[the_form].elements[basename + i + 'r']) != 'undefined') { - document.forms[the_form].elements[basename + i + 'r'].checked = do_check; - } - } - - return true; -} // end of the 'setCheckboxesRange()' function // added 2004-05-08 by Michael Keck // copy the checked from left to right or from right to left @@ -1252,4 +1215,4 @@ function pdfPaperSize(format, axis) { if (axis == 'x') return 612.00; else return 936.00; break; } // end switch -} +} \ No newline at end of file