checkboxes[$boxName] = new CheckboxField($boxName, $option); $this->addSubField($this->checkboxes[$boxName]); $i++; } $this->otherChoice = new TextField($name . FF_SEP . "other", FfLH::t("Other") . ":", FORM_FIELD_NOT_REQUIRED, 40, 1, null); $this->otherBox = new CheckboxField($name . FF_SEP . "other_box", FfLH::t("Other") . ":"); $this->otherBox->setExtraHtml("onclick=\"otherChoice=document.getElementById('" . $this->otherChoice->getId() . "');if(!this.checked)otherChoice.value='';\""); $this->otherChoice->setExtraHtml("onclick=\"otherBox=document.getElementById('" . $this->otherBox->getId() . "');otherBox.checked=true;\" onkeydown=\"otherBox=document.getElementById('" . $this->otherBox->getId() . "');if(this.value.length>0)otherBox.checked=true;\""); $this->addSubField($this->otherChoice); $this->addSubField($this->otherBox); $this->cols = $cols; if ($rows != null) $this->rows = $rows; else $this->rows = sizeof($this->checkboxes); $this->includeOtherChoice = $includeOtherChoice; } /** * Creates a new CheckboxGroupField. * @param string name the name of the form field. This value must not be a SQL reserved word and should follow all the standard variable naming conventions in PHP. * @param string label this form field's label. The label is the printable text that is typically displayed on the left side of the field. * @param int required Sets whether the field must be filled in and whether it looks like it must be filled in: FORM_FIELD_REQUIRED, FORM_FIELD_NOT_REQUIRED, FORM_FIELD_LOOKS_REQUIRED or FORM_FIELD_REQUIRED_NO_LOOK * @param array options A string array of options associated with each checkbox * @param int rows The number of rows used to display the radio button choices or if null is supplied each button will appear on it's own line. The rows restriction is ranked higher than the cols restriction. * @param int cols The number of columns used to display the radio button choices. Defaulted to 1. * @param boolean includeOtherChoice True if the other field should be displayed so that the user can enter an other string when their desired selection doesn't exist * @see FORM_FIELD_REQUIRED * @see FORM_FIELD_NOT_REQUIRED * @see FORM_FIELD_LOOKS_REQUIRED * @see FORM_FIELD_REQUIRED_NO_LOOK * @since FORMfields v1.0 * @deprecated deprecated as this constructor syntax is not expected in PHP 5 - will be removed once PHP 5 becomes a minimum requirement for FORMfields */ function CheckboxGroupField($name, $label, $required, $options, $rows=null, $cols=1, $includeOtherChoice=false) { $this->__construct($name, $label, $required, $options, $rows, $cols, $includeOtherChoice); } /** * Returns the HTML to display a single checkbox. * @param CheckboxField checkbox a checkbox to display * @return the HTML to display a single checkbox * @since FORMfields v3.0 */ function getSingleCheckboxTag($checkbox) { return $checkbox->getEditableFieldTag() . ""; } /** * Returns the HTML used to display the input portion of this * field. * @return string the HTML used to display the input portion of this field * @since FORMfields v3.0 */ function getEditableFieldTag() { $html = ""; $choices = array(); foreach ($this->checkboxes as $i=>$checkbox) { $choices[$i] = $this->getSingleCheckboxTag($checkbox); } $ts = new TableSet(null, "ffTableSetClear"); $ts->loadRowsAndColumns($choices, $this->rows, $this->cols); if ($this->includeOtherChoice) { $ts->addRow(array("
" . $this->getSingleCheckboxTag($this->otherBox) . " " . $this->otherChoice->getFieldTag() . "
")); } $html .= $ts->getTableTag(); return $html; } /** * Returns the value of this form field. * @return array a string array of options * @since FORMfields v3.0 */ function getValue() { $value = array(); foreach($this->checkboxes as $checkbox) { if (!$checkbox->isEmpty()) { array_push($value, $checkbox->getLabel()); } } if ($this->otherBox->getValue() && $this->otherChoice->getValue()) { array_push($value, $this->otherChoice->getValue()); } return $value; } /** * Sets the value of this field. * @param array values an array of strings equal to the selected options * @since FORMfields v3.0 */ function setValue($values) { parent::setValue($values); if (is_array($values)) { $this->clearValue(); foreach ($values as $value) { $match = false; foreach ($this->checkboxes as $i=>$checkbox) { if ($checkbox->getLabel() === $value) { $this->checkboxes[$i]->setValue("true"); $match = true; break; } } // If there wasn't a match then we assume it is the other value if ($this->includeOtherChoice && !$match && !$this->isBlank($value)) { $this->otherChoice->setValue($value); $this->otherBox->setValue("true"); //$this->otherChoice->setEnabled(true); } } } } /** * Sets the database value of this field. A database * value can be different than the field's actual value. For * example a phone number may have the value * "973-746-3233" but its database value would be "9737463233" * @param string value a comma separated list of values that is comma escaped * @since FORMfields v3.0 */ function setDbValue($value) { $this->setValue(FfHelper::stringToArray($value)); } /** * Retrieves the posted field value. In other words, sets this * field value using the appropriate values in $_REQUEST. * @since FORMfields v3.0 */ function getParameter() { parent::getParameter(); } /** * Checks for field errors detected by this field, including * a check for blank. This method ensures that if the other * choice is checked, that a value for other is supplied. * If an error is detected, the setError() method is called * to set the appropriate error message. * @return boolean true if there is an error or false otherwise * @since FORMfields v3.0 */ function isValid() { if (!parent::isValid()) return false; if ($this->isEmpty() && $this->otherBox->isEmpty()) return true; if ($this->includeOtherChoice && !$this->otherBox->isEmpty() && $this->otherChoice->isEmpty()) { $this->setError(FfLH::t("please specify a value for other") . "!"); return false; } return true; } } ?> healthelinks :: Consumer Health ">
HOME | ABOUT US | CONTACT US      
Heathelinks Logo
DISEASES & CONDITIONS | MEDICINES | PROCEDURES & SURGICAL OPERATIONS | LAB TESTS
MAJOR HEALTH SITES
HEALTH CARE REFORM
DICTIONARIES
CLINICAL TRIALS
WELLNESS
FOR KIDS
SENIOR HEALTH
WOMEN'S HEALTH
FINDING HEALTH CARE
BE A SMART PATIENT
END OF LIFE ISSUES
ENVIRONMENTAL HEALTH
RECURSOS EN ESPAƑOL
We Welcome Your Comments

Thank you for visiting healthelinks.

  • Did you find what you were looking for?
  • Did healthelinks help you find an answer to your health question?
  • Do you have a suggestion for additional diseases, tests or procedures?

The LSU Health Shreveport Health Sciences Library operates this Web site and welcomes your feedback. Questions or comments can be sent to the address below. Although we appreciate your comments, the volume of e-mail makes it impossible to reply to all of the messages we receive.

Please note: We cannot answer individual medical questions or give medical advice. If you have questions or concerns, please consult your family physician.

We do not accept unsolicited recommendations for links to commercial web sites, and such e-mails may not receive a response.

You may contact us by

E-mail: madams@lsuhsc.edu
Phone: 318.675.5448
Fax: 318-675-5442
Mail: LSU Health Shreveport Health Sciences Library
PO Box 33932
Shreveport, LA 71130-3932

Or by submitting this form:

  • * - required


  • If you would like a response to your question or comment, please fill in your contact information in the fields below:

  • Should be Empty:
Disclaimer: healthelinks is intended for information purposes only, not to offer medical advice.
Please consult your doctor about any personal health concerns.
Copyright @ 2005-2018 LSU Health Shreveport Health Sciences Library. All rights reserved
LSU Health Shreveport Health Sciences Library | 1501 Kings Highway | Shreveport, LA 71130 | 318.675.5445