<?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> © All rights reserved </div> </body>
$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> <div id="bottom" style="position:fixed;bottom: 0;width:98%;text-align: right">
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>