Option
Option Du er her: /  Forsiden  /  Kildekoden  /  Form  /  Option   Login nu   Login
Option
 ««« Se kilde koden
Option
Option Basic Base Component Db Db-basket Dto Form  Form-elements Jquery Layout Menu Menu-fisheye Mvc Tab Table Template Util
Option
Option
Option Index
 
Tilbage

Navn : Option.php


Sample code, tutorial

Sådan benyttes komponenten Option klassen

Først skal du inkludere den fil der beskriver komponenten, som en klasse fil

  • <?
    require_once(HTML_PACKAGE_PATH.'/Option.php');
    ?>

Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):

  • <?
    Option
    ::display($param1, $param2, $param3, ...);
    ?>

eller du kan lave en instance af komponenten og benytte metoderne direkte:

  • <?
    $object
    = new Option($param1, $param2, $param3, ...);
    print
    $object->getHtml();
    ?>

Parent html

Sådan vises komponenten Option klassen


PHP source code

Den fulde PHP kildekode for Option klassen

<?
/**
* @package form
* @filesource
* @see HTML_FORM_COMPONENT_PATH.'/Option.php'
* @copyright (c) http://Finn-Rasmussen.com
* @license http://Finn-Rasmussen.com/license/ myPHP License conditions
* @author http://Finn-Rasmussen.com
* @version 1.10
* @since 22-feb-2007
*/

/**
* The required files
*/
require_once(HTML_BASE_UTIL_PATH.'/Element.php');
require_once(
HTML_BASE_UTIL_PATH.'/Htmlspecialchars.php');

/**
* Generates an OPTION form element
* <code>
* Usage:
*   $option = new Option($text,$value,$selected,$title,$label);
*   print $option->getHtml();
* Or
*   Option::display($text,$value,$selected,$title,$label);
* </code>
* @package form
*/

class Option extends Element {
    
/**
     * @var String $text The text to show to the user
     */
   
var $text     = '';

    
/**
     * @var String $selected The 'selected' text or ''
     */
   
var $selected = '';

    
/**
     * @var String $label The label to show to the user
     */
   
var $label    = '';

   
/**
    * Constructor
    * @param String $text     The text to show
    * @param String $value    The value, if any
    * @param String $selected The option is selected
    * @param String $title    The tooltip
    * @param String $label    The label
    */
    
function Option($text,$value='',$selected='',$title='',$label='') {
        
$name      = ''; // Not supported
        
$class     = '';
        
$tabindex  = '';
        
$onclick   = '';
        
$accesskey = '';
        
$this->Element($name,$value,$class,$title,$tabindex,$onclick,$accesskey);
        
$this->text     = $text;
        
$this->selected = $selected;
        if (
$this->selected != '' && $this->selected != 'selected') {
            die(
'File: '.__FILE__."<br />\r\nLine: ".__LINE__."<br />\r\n".'Unknown option attribute found for selected='.$this->selected.' accepted values are "" or "selected"');
        }
        
$this->label    = $label; // !=''?$label:$text
    
}

   
/**
    * Returns the html for the option control
    * @return String the complete html
    */
   
function getHtml() {
      
$html  = $this->html;
      
$html .= "\t<option";
      
$html .= $this->getAttribute('value');
      
$html .= $this->getAttribute('selected');
      
$html .= $this->getAttribute('title');
      
$html .= $this->getAttribute('label');
      
$html .= '>';
      
$html .= Htmlspecialchars::encode($this->text); // Translate html special chars
      
$html .= "</option>\r\n";
      return
$html;
   }

   
/**
    * Display html
    * <code>
    * Usage:
    *    Option::display($text,$value,$selected,$title,$label);
    * </code>
    * @param String $text     The text to show
    * @param String $value    The value, if any
    * @param String $selected The option is selected
    * @param String $title    The tooltip
    * @param String $label    The label
    */
   
function display($text,$value='',$selected='',$title='',$label='') {
      
$html = new Option($text,$value,$selected,$title,$label);
      
$html->addHtml();
   }
}
?>

HTML source code

Den fulde HTML kildekode for Option klassen

<?
    
<option value="Test">Test</option>

?>

Class methods

Her er 'klasse metoderne' for Option klassen:

  • object
  • getclassname
  • getmsg
  • addhtml
  • gethtml
  • tostring
  • getcachefilename
  • save
  • content
  • stop
  • html
  • setobject
  • set
  • get
  • getattribute
  • gettag
  • add
  • getsizeof
  • getelement
  • getelements
  • gettoogle
  • getmaximize
  • getminimize
  • newtriangle
  • display
  • showsource
  • element
  • getvalue
  • setid
  • setonfocus
  • setonblur
  • id
  • option

Object vars

Her er 'objekt variable' for Option klassen:

  • html =>
  • sql =>
  • elements => Array
  • sizeof => 0
  • name =>
  • id =>
  • value => Test
  • class =>
  • title =>
  • tabindex =>
  • onclick =>
  • accesskey =>
  • onfocus =>
  • onblur =>
  • text => Test
  • selected =>
  • label =>

Option

Vis denne side på danmark

Vis denne side på Germany

Vis denne side på England

Vis denne side på France

Vis denne side på Italy

Vis denne side på Norge

Vis denne side på Sverige

Vis denne side på USA


 
Option
Option Copyright @ 1999-2009 www.Finn-Rasmussen.com Powered by myPHP Version 1.10
Option