Example #1
0
?>
<script>
function search_casesensitive_and_startbeginning(term, text){
    return (text.indexOf(term)>=0)
            &&
            text.toUpperCase().indexOf(term.toUpperCase())==0;
}
</script>
<input id="searchme" type="hidden" />



<h2>Disable Search</h2>
Note that when set_max_input_length() or set_min_input_length() method is presented, disable_search() is ignored.<br />
<?php 
$pac2 = new C_PhpAutocomplete('foobar');
$pac2->disable_search();
$pac2->display('SELECT');
?>
<select id="foobar">
    <option></option>
    <option id="1">Apple</option>
    <option id="2">Google</option>
    <option id="3">Microsoft</option>
    <option id="4">Facebook</option>
    <option id="5">Twitter</option>
</select>



<?php

require_once "../conf.php";
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PHP Autocomplete - Existing Select Element (Multiple)</title>
</head>
<body>

<h2>Existing Select Element (Multiple)</h2>
<?php 
$pac3 = new C_PhpAutocomplete('foobar2');
$pac3->display('SELECT');
?>
<select id="foobar2" multiple>
    <option></option>
    <option id="1">Apple</option>
    <option id="2">Google</option>
    <option id="3">Microsoft</option>
    <option id="4">Facebook</option>
    <option id="5">Twitter</option>
</select>


<div id="bottom" style="position:fixed;bottom: 0;width:98%;text-align: right">
    <a href="http://phpautocomplete.com">phpautocomplete.com</a> &copy; All rights reserved
</div>
</body>
$pac = new C_PhpAutocomplete('init_selection_INPUT', $data);
$pac->enable_multiple(false);
// hidden input only
$pac->set_init_selection(array("id" => "1", "text" => "Apple"));
$pac->display();
?>
<input id="init_selection_INPUT" type="hidden" value="" />
<a href="#" onclick="get_init_selection('#init_selection_INPUT')">show selected value</a>




<h2>Set Initial Selection (HIDDEN INPUT - Multiple Select)</h2>
<?php 
$data = array(array('id' => 1, 'text' => 'Apple'), array('id' => 2, 'text' => 'Google'), array('id' => 3, 'text' => 'Microsoft'), array('id' => 4, 'text' => 'Facebook'), array('id' => 5, 'text' => 'Twitter'));
$pac = new C_PhpAutocomplete('init_selection_INPUT2', $data);
$pac->enable_multiple(true);
// hidden input only
$pac->set_init_selection(array(array("id" => "1", "text" => "Apple"), array("id" => "5", "text" => "Twitter")));
$pac->display();
?>
<input id="init_selection_INPUT2" type="hidden" value="" />

<script>
    function get_init_selection(ctrl_id){
        alert($(ctrl_id).select2("val"));
        return false;
    };
</script>
<a href="#" onclick="get_init_selection('#init_selection_INPUT2')">show selected value</a>
<?php

require_once "../conf.php";
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PHP Autocomplete - Hidden Input with Data</title>
</head>
<body>

<h2>Hidden Input with Data</h2>

<?php 
$data = array(array('id' => 1, 'text' => 'Apple'), array('id' => 2, 'text' => 'Google'), array('id' => 3, 'text' => 'Microsoft'), array('id' => 4, 'text' => 'Facebook'), array('id' => 5, 'text' => 'Twitter'));
$pac = new C_PhpAutocomplete('my_hidden_input', $data);
$pac->enable_multiple(true);
// hidden input only
$pac->display();
?>
<input id="my_hidden_input" type="hidden" />

<div id="bottom" style="position:fixed;bottom: 0;width:98%;text-align: right">
    <a href="http://phpautocomplete.com">phpautocomplete.com</a> &copy; All rights reserved
</div>
</body>
</html>
<?php

require_once "../conf.php";
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PHP Autocomplete - Existing Select Element (Single)</title>
</head>
<body>

<h2>Existing Select Element (Single)</h2>
<?php 
$pac2 = new C_PhpAutocomplete('foobar');
$pac2->display('SELECT');
?>
<select id="foobar">
    <option></option>
    <option id="1">Apple</option>
    <option id="2">Google</option>
    <option id="3">Microsoft</option>
    <option id="4">Facebook</option>
    <option id="5">Twitter</option>
</select>



<div id="bottom" style="position:fixed;bottom: 0;width:98%;text-align: right">
    <a href="http://phpautocomplete.com">phpautocomplete.com</a> &copy; All rights reserved
</div>
Example #6
0
<?php

require_once "../conf.php";
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PHP Autocomplete - </title>
</head>
<body>

<h2>Auto-generated Hidden Input</h2>
<?php 
$data = array(array('id' => 1, 'text' => 'Apple'), array('id' => 2, 'text' => 'Google'), array('id' => 3, 'text' => 'Microsoft'), array('id' => 4, 'text' => 'Facebook'), array('id' => 5, 'text' => 'Twitter'));
$new_data = array(array('id' => 11, 'text' => 'ABC'), array('id' => 22, 'text' => 'OPQ'), array('id' => 33, 'text' => 'XYZ'));
$pac = new C_PhpAutocomplete('load_data', $data);
$pac->load_data($new_data);
// this will overwrite $data;
$pac->display();
?>
<input id="load_data" type="hidden" />




<div id="bottom" style="position:fixed;bottom: 0;width:98%;text-align: right">
    <a href="http://phpautocomplete.com">phpautocomplete.com</a> &copy; All rights reserved
</div>
</body>
</html>