Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Form  /  Option   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tl.gif Base tr.gif tl.gif Basic tr.gif tl.gif Dto tr.gif tls.gif     Form  trs.gif tl.gif Language tr.gif tl.gif Layout tr.gif tl.gif Menu tr.gif tl.gif Mvc tr.gif tl.gif Netbank.eksperter.dk tr.gif tl.gif Tab tr.gif tl.gif Table tr.gif tl.gif Util tr.gif
blank.gif
blank.gif
arrow-headline.gif Index
MenuLink  MenuLeft  
Tilbage

Skjul: Navn

Option.php


Vis: Sample code, tutorial

Option, 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();
    ?>

Skjul: Sådan vises komponenten

Option, Sådan vises komponenten

Sådan vises komponenten Option klassen


Vis: PHP source code

Option, PHP source code

Den fulde PHP kildekode for Option klassen

<?php
/**
 * @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.11
 * @since 27-nov-2009
 */

/**
 * 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 
     */
   
protected $text     '';

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

    
/**
     * @var String $label The label to show to the user 
     */
   
protected $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 __construct($text$value=''$selected=''$title=''$label='') {
        
$name      ''// Not supported
        
$class     '';
        
$tabindex  '';
        
$onclick   '';
        
$accesskey '';
        
parent::__construct($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
    */
   
public static function display($text$value=''$selected=''$title=''$label='') {
      
$html = new Option($text$value$selected$title$label);
      
$html->addHtml();
   }
}
?>

Vis: HTML source code

Option, HTML source code

Den fulde HTML kildekode for Option klassen

<?
<!-- DEBUGOption -->
    <
option value="Test">Test</option>

?>

Vis: Class methods

Option, Class methods

Her er 'klasse metoderne' for Option klassen:

  • __construct
  • getHtml
  • display
  • getValue
  • setId
  • setOnfocus
  • setOnblur
  • id
  • setObject
  • set
  • get
  • getAttribute
  • getTag
  • add
  • getSizeof
  • getElement
  • getElements
  • getToogle
  • getMaximize
  • getMinimize
  • newTriangle
  • getStartHtml
  • getEndHtml
  • showsource
  • getClassName
  • getMsg
  • addHtml
  • __toString
  • getCacheFileName
  • save
  • content

Vis: Object vars

Option, Object vars

Her er 'objekt variable' for Option klassen:

  • html =>
  • sql =>

MenuRight 
triangle.gif

Dansk

Deutch

English (UK)

France

Italy

Norsk

Svensk

English (USA)


 
blank.gif
MenuBottom 
triangle.gif Copyright @ 1999-2010 www.Finn-Rasmussen.com Powered by myPHP Version (5.3.3-7+squeeze3) 1.11
blank.gif