­

SELECT or INPUT?

The PHP Autocomplete can be attached an existing HTML Select or an hidden input field.When attached to a Select tag, pass “SELECT” to display() method; or “INPUT” when attached to a hidden Input field. The default value value is “INPUT” when left it blank. e.g.

$pac -> display("SELECT");

So when to use SELECT or INPUT? If you want to transform an existing HTML Select tag into auto-complete control, use “SELECT”; otherwise, use “INPUT” referencing to an input type=’hidden’ tag. In order to take advantage of custom data, use “INPUT”, otherwise data is parsed from Select’s option tags.

<?php
$data =
    array(
        array('id'=>1, 'text'=>'Japan'),
        array('id'=>2, 'text'=>'USA'),
        array('id'=>3, 'text'=>'Hong Kong'),
        array('id'=>4, 'text'=>'Canada'),
        array('id'=>5, 'text'=>'Brazil')
    );
$pac = new C_PhpAutocomplete('country', $data);
$pac -> display();
?>
<input type="hidden" id="country">

No related content found.

Tags: ,

PHP Autocomplete
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.