WebSite-PHP Framework PHP
Multi language
Simple Ajax mode
No HTML, no JavaScript
URL rewriting
Mail sending
Sitemap - RSS - Web service
Download WebSite-PHP FrameWork now
 


Loading
 


Tutorial : TextBox search 
with autocomplete and dynamic filter

Tutorials

>

Tutorial Textbox

>

Tutorial : TextBox search with autocomplete and dynamic filter


Textbox-09: Tutorial of the composant Textbox of the PHP FrameWork WebSite-PHP.

Tutorial : TextBox search with autocomplete and dynamic filter:



Go back to tutorial of the componant Textbox



Source code

Source code


File: /pages/tutorials/textbox/textbox-09.php

<?php
class Textbox09 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : TextBox search 
                    with autocomplete and dynamic filter"
;
        
        
$form = new Form($this);
        
        
// Create ComboBox object (filter)
        // List of actif and inactif is available on:
        // http://www.website-php.com/en/tutorials/database/database-05.html
        // You can modify the list of inactif on:
        // http://www.website-php.com/en/tutorials/database/database-07.html
        
$filter = new ComboBox($form);
        
$filter->addItem(1"ACTIF");
        
$filter->addItem(0"INACTIF");
        
        
// Create TextBox object
        
$search_text = new TextBox($form);
        
        
// Create AutoCompleteEvent object
        
$autocompete_event = new AutoCompleteEvent($form);
        
$autocompete_event->onSelect("onSelectAutoComplete");
        
$autocompete_event->setAjaxEvent();
        
$autocompete_event->disableAjaxWaitMessage();
        
        
// Create AutoComplete object (with filter in the URL)
        
$autocomplete = new AutoComplete(
            new 
Url("xml/textbox-search.json?".
            
"filter='+$('#".$filter->getId()."').val()+'"), 
            
1$autocompete_event);

        
// Refresh URL when change filter
        
$filter->onChangeJS("$('#".$search_text->getId()."').autocomplete(".
            
"'option', 'source', '".$this->getBaseLanguageURL().
            
"xml/textbox-search.json?".
            
"filter='+$('#".$filter->getId()."').val());");
            
        
// Set autocomplete on the TextBox
        
$search_text->setAutoComplete($autocomplete);
        
$form->setContent(new WSPObject($filter$search_text));
        
        
$this->render $form;
    }
    
    public function 
onSelectAutoComplete($sender$id) {
        
$this->addObject(
            new 
DialogBox("onSelectAutoComplete"
                                
"URL: ".$id)
            );
    }
}
?>


Go back to tutorial of the componant Textbox



Share

 


Copyright © 2009-2024 WebSite-PHP Framework PHP
Home Documentation Download Quick start Tutorials Wiki Issue Tracker