diff --git a/html/js/scripts.js b/html/js/scripts.js index 6831dc27b..02c4792c3 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1032,6 +1032,25 @@ function select_checkbox(form_id) } } } +/** + * select all the checkbox in a given form if the specific attribute + * has the given value + * @param form_id id of the form + * @param attribute name + * @param attribute value + */ +function select_checkbox_attribute(form_id,p_attribute_name,p_attribute_value) +{ + var form = $(form_id); + for (var i = 0; i < form.length; i++) + { + var e = form.elements[i]; + if (e.type === 'checkbox' && e.getAttribute(p_attribute_name)==p_attribute_value) + { + e.checked = true; + } + } +} /** * unselect all the checkbox in a given form * @param form_id id of the form diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php index 18909af13..33307eedd 100755 --- a/include/lib/html_input.class.php +++ b/include/lib/html_input.class.php @@ -449,6 +449,24 @@ class HtmlInput $r.=''; return $r; } + /** + * Anchor Html with javascript + *@param $action action action to perform (message) without onclick + *@param $javascript javascript to execute + *@param $id is the DOM element id + *@param $p_class CSS class of the button + *@param $p_symbole raw symbole to add to the action message + */ + static function anchor_action($action,$javascript,$id=NULL,$p_class="button",$p_symbole="") + { + if ($id==NULL){ + $id=uniqid("xx"); + } + $r=""; + $r.=''.$p_symbole.h($action).''; + return $r; + + } /** * button Html with javascript *@param $action action action to perform (message) without onclick @@ -1025,4 +1043,20 @@ EOF; $js=HtmlInput::button_action(_('Nouvel événement'),'action_add('.$dossier.')','xx','smallbutton'); return $js; } + /** + * Insert attribute inside a INPUT TYPE, these attribute can be retrieved + * in javascript with element.getAttribute or changed with element.setAttribute + * example insert my_attribute into a checkbox + * @return string to insert into the HTML node + * + */ + function get_node_attribute() + { + $r=""; + $nb_attribute=count($this->attribute); + for ($i=0;$i < $nb_attribute;$i++) { + $r.=sprintf(' %s="%s" ',$this->attribute[$i][0] ,$this->attribute[$i][1]); + } + return $r; + } } diff --git a/include/lib/icheckbox.class.php b/include/lib/icheckbox.class.php index ff7195fdf..13177dc10 100644 --- a/include/lib/icheckbox.class.php +++ b/include/lib/icheckbox.class.php @@ -36,6 +36,7 @@ class ICheckBox extends HtmlInput $check=( $this->selected==true )?"checked":"unchecked"; $r='get_node_attribute(); $r.=' '.$this->disabled." ".$this->javascript.'>'; $r=$r." $this->label";