ICheckBox : add attribute to allow to select checkbox thanks its attribute
with the js select_checkbox_attribute
This commit is contained in:
parent
4fd8bcb2d3
commit
66d68954db
3 changed files with 54 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -449,6 +449,24 @@ class HtmlInput
|
|||
$r.='</div>';
|
||||
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.='<a id="'.$id.'" class="'.$p_class.'" onclick="'.$javascript.'">'.$p_symbole.h($action).'</a>';
|
||||
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 <input type="checkbox" "my_attribute"="XX">
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class ICheckBox extends HtmlInput
|
|||
$check=( $this->selected==true )?"checked":"unchecked";
|
||||
$r='<input type="CHECKBOX" id="'.$this->id.'" name="'.$this->name.'"'.' value="'.$this->value.'"';
|
||||
$r.=" $check";
|
||||
$r.=$this->get_node_attribute();
|
||||
$r.=' '.$this->disabled." ".$this->javascript.'>';
|
||||
|
||||
$r=$r." $this->label";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue