Source for file HTMLRadioGroup.class.php
Documentation is available at HTMLRadioGroup.class.php
* For including this file you have to define the constant "CLASSPATH".
* Because every include in the framework depends on the CLASSPATH definition.
* The CLASSPATH means the relative path to the folder that contains the
echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
require_once( CLASSPATH. "forms/items/ABSTHTMLFormItem.class.php" );
* @author Daniel Plücken <daniel@debakel.net>
* @license http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
* @copyright Copyright (C) 2004 Daniel Plücken <daniel@debakel.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* Stores whether the radio buttons should arrange horizontal; Arrangement
* with or without breaks.
* @author Daniel Plücken <daniel@debakel.net>
* @param string $name Name of the radio button group.
* @param array $labelArr Array with the label of each radio
* @param array $valueArr Array with the value of each radio
* @param string $selectedValue Value to be select.
* @param string $horizontal Whether the radio buttons should
$this->value = $selectedValue;
* Adds a new radiobutton to the group.
* @author Daniel Plücken <daniel@debakel.net>
function addButton( $label = "", $value = "" )
for( $i = 0; $i < max( count( $label ), count( $value ) ); $i++ )
* Adding an array to this object, that carries the javascript for the
* onMouseup-tag of each radiobutton.
* @author Daniel Plücken <daniel@debakel.net>
* @param array $array Array with the javascripts of each radio button
* they should execute on left mouse button up.
* Returns a string which contains a function of a javascript to check the
* radiobutton which value is the given one.
* @author Daniel Plücken <daniel@debakel.net>
$out = " function setRadio( field, wert )\r\n";
$out .= " üfor( i = 0; i < field.length; i++ )\r\n";
$out .= " if( field[i].value == wert )\r\n";
$out .= " field[i].checked = true;\r\n";
* Returns an if-order of a javascript to check whether this item is NOT
* @author Daniel Plücken <daniel@debakel.net>
* @param string $formName
. $this->name. "[0].checked != true";
$out .= "\r\n && document.". $this->parentform->name. "."
. $this->name. "[". $i. "].checked != true";
* Set the value of inline styles of the labels for the radiobuttons of the
* @author Daniel Plücken <daniel@debakel.net>
* Generates the sourcecode to build this object and returns it.
* @author Daniel Plücken <daniel@debakel.net>
$out .= "unset( \x24LabelArr );\r\n";
$out .= "unset( \x24ValueArr );\r\n";
$out .= "\x24LabelArr = array(\r\n";
for( $i = 0; $i < $cntLab ; $i++ )
$comma = ( $cntLab - 1 != $i )
$out .= "\x24ValueArr = array(\r\n";
for( $i = 0; $i < $cntVal ; $i++ )
$comma = ( $cntVal - 1 != $i )
$out .= "unset( \x24value );\r\n";
$out .= "\x24value = \x24_POST[\"". $this->getName(). "\"]\r\n"
. " .\x24_GET[\"". $this->getName(). "\"];\r\n";
$out .= "\x24input[] = new HTMLRadioGroup(\r\n"
$tmp = $this->getSelectedValue();
? "if( \x24value === \"\" )\r\n"
." \x24input[count(\x24input)-1]->setSelectedValue( \"".$tmp."\" );\r\n"
* Returns a generated string based on the attributes of this object.
* @author Daniel Plücken <daniel@debakel.net>
* @param string forminput POST or GET or REQUEST
function get( $forminput = "" )
$out .= "<input type=\"radio\"\r\n"
. " name=\"". $this->name. "\"\r\n"
. " id=\"". $this->id. "_". $i. "\"";
: " disabled=\"disabled\"";
|| $forminput == "REQUEST"
$out .= "<? if( \x24_". $forminput. "['". $this->name. "'] "
? "\r\n checked=\"checked\""
? "<label for=\"". $this->id. "_". $i. "\""
} // END of class HTMLRadioGroup
|