Cjax Framework



Try typing a letter, it should find all finding starting with that letter. This is just a demonstration, funcationality is intended to be adapted with a database. The backend controller is test data only.


Examples


PHP
<?php 

//first bild text element search to the ajax request
//pass |search|, passes the value of search field.
//search_result is the contained div
//keyup is the event (see: $ajax->Exec() in API table)
$ajax->keyup('search',$ajax->call('ajax.php?search/string/|search|','search_result'));

?>
Controller:
PHP
<?php 

//controllers/search.php
class search {

    function 
string($string)
    {
        
// Fill up array with some data
        
$a[]="Anna";
        
$a[]="Amanda";
        
$a[]="Amelia";
        
$a[]="Armando";
        
$a[]="Brittany";
        
$a[]="Bob";
        
$a[]="Bill";
        
$a[]="Cinderella";
        
$a[]="Cindy";
        
$a[]="Carlos";
        
$a[]="Diana";
        
$a[]="Doris";
        
$a[]="Eva";
        
$a[]="Eve";
        
$a[]="Evita";
        
$a[]="Fiona";
        
$a[]="Gunda";
        
$a[]="Hege";
        
$a[]="Inga";
        
$a[]="Johanna";
        
$a[]="Kitty";
        
$a[]="Linda";
        
$a[]="Nina";
        
$a[]="Ophelia";
        
$a[]="Petunia";
        
$a[]="Raquel";
        
$a[]="Sunniva";
        
$a[]="Tove";
        
$a[]="Unni";
        
$a[]="Violet";
        
$a[]="Liza";
        
$a[]="Liz";
        
$a[]="Elizabeth";
        
$a[]="Ellen";
        
$a[]="Wenche";
        
$a[]="Vicky";
        
$a[]="Quinton";
        
$a[]="Yancy";
        
$a[]="Yakecan";

        
$out = array();
        foreach(
$a as $v) {
            if(
substr(strtolower($v), 0strlen($string)) == strtolower($string)) {
                
$out[] = $v;
            }
        }
        die(
'<pre>'.print_r($out,1).'<pre>');
    }
}

?>

Try it

Type Something


Previous Topic:  Previous Class    ·   Top of Page   ·   Demos Home   ·  

CodeIgniter  ·  Copyright © 2006 - 2012  ·  Cjax