+ add html::checkAll function.

This commit is contained in:
chencongzhi520@gmail.com
2012-04-30 02:52:12 +00:00
parent 58eee83c99
commit 3d89f5c837
+43
View File
@@ -219,6 +219,49 @@ class html
return $string;
}
/**
* Create tags like "<input type='button' onclick='checkAll()'/>"
*
* @param string $name the name of the button tag.
* @param string $value the value of the button tag.
* @param string $scope the scope of checkall.
* @param string $attrib other attribs.
* @return string
*/
static public function checkAll($name, $value, $scope = "", $attrib = "")
{
$string = <<<EOT
<script type="text/javascript">
function checkAll(scope)
{
if(scope)
{
$('#' + scope + ' input').each(function()
{
$(this).attr("checked", true)
});
}
$('input').each(function()
{
$(this).attr("checked", true)
});
}
</script>
EOT;
if($scope)
{
$string .= "<span><input type='button' name='$name' value='$value' onclick='checkAll($scope)'";
}
else
{
$string .= "<span><input type='button' name='$name' value='$value' onclick='checkAll()'";
}
$string .= $attrib;
$string .= " /> </span>\n";
return $string;
}
/**
* Create tags like "<input type='text' />"
*