Added a function to print a standard html checkbox

This commit is contained in:
stronk7
2005-06-28 16:52:46 +00:00
parent 7f80097841
commit 3471fa7ba0
+31
View File
@@ -734,6 +734,37 @@ function choose_from_radio ($options, $name, $checked='') {
echo $output;
}
/** Display an standard html checkbox with an optional label
*
* @param string $name The name of the checkbox
* @param string $value The valus that the checkbox will pass when checked
* @param boolean $checked The flag to tell the checkbox initial state
* @param string $label The label to be showed near the checkbox
* @param string $alt The info to be inserted in the alt tag
*/
function print_checkbox ($name, $value, $checked = true, $label = '', $alt = '') {
if (!$name) {
$name = 'unnamed';
}
if (!$alt) {
$alt = 'checkbox';
}
if ($checked) {
$strchecked = ' checked="checked"';
}
$output = '<span class="checkbox '.$name."\">";
$output .= '<input name="'.$name.'" type="checkbox" value="'.$value.'" alt="'.$alt.'"'.$strchecked.' />';
$output .= $label;
$output .= '</span>'."\n";
echo $output;
}
/**
* Implements a complete little popup form
*