WebSite-PHP Framework PHP
Multi langues
Mode Ajax simple
Aucun HTML, aucun JavaScript
URL rewrinting
Envoi d'email
Sitemap - RSS - Web service
Télécharger le Framework WebSite-PHP maintenant
 


Loading
 


Tutoriel Button

Tutoriels

>

Tutoriel Button



Tutoriel 1 : Simple Button
Fichier: /pages/tutorials/button/button-01.php

<?php
class Button01 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Simple Button";
        
        
$this->render = new Button($this);
        
$this->render->setValue("Validate");
    }
}
?>


Tutoriel 2 : Simple Button with javascript alert on click
Fichier: /pages/tutorials/button/button-02.php

<?php
class Button02 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Simple Button with 
                                    javascript alert on click"
;
        
        
$this->render = new Button($this);
        
$this->render->setValue("Validate");
        
$this->render->onClickJs("alert('click');");
    }
}
?>


Tutoriel 3 : Button with form
Fichier: /pages/tutorials/button/button-03.php

<?php
class Button03 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Button with form";
        
        
$form = new Form($this);
        
        
$button = new Button($form);
        
$button->setValue("Validate");
        
        
$form->setContent($button);
        
$this->render $form;
    }
}
?>


Tutoriel 4 : Button with form, callback method on click
Fichier: /pages/tutorials/button/button-04.php

<?php
class Button04 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Button with form, 
                                    callback method on click"
;
        
        
$form = new Form($this);
        
        
$button = new Button($form);
        
$button->setValue("Validate")->onClick("onClickButton");
        
        
$form->setContent($button);
        
$this->render $form;
    }
    
    public function 
onClickButton($sender) {
        
$this->addObject(new JavaScript("alert('click');"));
    }
}
?>


Tutoriel 5 : Button with input text in form, callback method on click in AJAX
Fichier: /pages/tutorials/button/button-05.php

<?php
class Button05 extends Page {
    private 
$text null;
    
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Button with input text 
                    in form, callback method on click in AJAX"
;
        
        
$form = new Form($this);
        
        
$this->text = new TextBox($form);
        
$this->text->setValue("Enter your text");
        
$this->text->setStripTags("<b><i>");
        
        
$button = new Button($form);
        
$button->setValue("Validate")->onClick("onClickButton");
        
$button->setAjaxEvent();
        
        
$form_obj = new WSPObject($this->text"<br/>"$button);
        
        
$form->setContent($form_obj);
        
$this->render $form;
    }
    
    public function 
onClickButton($sender) {
        
$dialog = new DialogBox("onClickButton"
                        
$this->text->getValue());
        
$this->addObject($dialog);
    }
}
?>


Tutoriel 6 : Button callback method and display log in console and alert box
Fichier: /pages/tutorials/button/button-06.php

<?php
class Button06 extends Page {
    private 
$text null;
    
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Button callback method  
                        and display log in console and alert box"
;
        
        
$form = new Form($this);
        
        
logConsoleInfo("This is an info");
        
logConsoleWarn("This is a warning");
        
logConsoleError("This is an error");
        
        
$this->text = new TextBox($form);
        
$this->text->setValue("Text to display in the console");
        
$this->text->setStripTags("<b><i>")->setWidth(200);
        
        
$button = new Button($form);
        
$button->setValue("Validate")->onClick("onClickButton");
        
$button->setAjaxEvent();
        
        
$form_obj = new WSPObject($this->text"<br/>"$button);
        
$form_obj->setAlign(WSPObject::ALIGN_CENTER);
        
        
$form->setContent($form_obj);
        
$this->render $form;
    }
    
    public function 
onClickButton($sender) {
        
alert($this->text->getValue());
        
logConsoleInfo($this->text->getValue());
    }
}
?>


Tutoriel 7 : Define default button
Fichier: /pages/tutorials/button/button-07.php

<?php
class Button07 extends Page {
    private 
$text null;
    
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Define default button";
        
        
$form = new Form($this);
        
        
$this->text = new TextBox($form);
        
$this->text->setValue("Enter your text");
        
$this->text->setStripTags("<b><i>");
        
        
$this->btn_val = new Button($form);
        
$this->btn_val->setValue("Validate");
        
$this->btn_val->onClick("onClickButton");
        
$this->btn_val->setAjaxEvent();
        
        
$this->btn_cancel = new Button($form);
        
$this->btn_cancel->setValue("Cancel");
        
$this->btn_cancel->onClick("onClickButton");
        
$this->btn_cancel->setAjaxEvent();
        
        
// To define default button
        
$this->btn_cancel->assignEnterKey();
        
        
$btn_table = new Table();
        
$btn_table->addRowColumns($this->btn_val
                                
$this->btn_cancel);
        
        
$form_obj = new WSPObject($this->text"<br/>"
                                
$btn_table);
        
        
$form->setContent($form_obj);
        
$this->render $form;
    }
    
    public function 
onClickButton($sender) {
        if (
$sender->getId() == $this->btn_val->getId()) {
            
$dialog = new DialogBox("onClickButton"
                            
$this->text->getValue());
        } else {
            
$dialog = new DialogBox("onClickButton"
                                    
"Cancel");
        }
        
$this->addObject($dialog);
    }
}
?>



Share

 


Copyright © 2009-2024 WebSite-PHP Framework PHP
Accueil Documentation Télécharger Quick start Tutoriels Wiki Issue Tracker