KoolAutoComplete supports search filtering option. To use this feature, you need to set searchFilter property of KoolAutoComplete's instance. There are two types of search filter:
- "startwith": KoolAutoComplete returns all items that start with user-typed text.
- "contain":KoolAutoComplete returns all items that contain user-typed text.
<?php
require $KoolControlsFolder."/KoolAutoComplete/koolautocomplete.php";
$kac = new KoolAutoComplete("kac");
$kac->scriptFolder = $KoolControlsFolder."/KoolAutoComplete";
$kac->width = "160px";
$kac->attachTo = "txtRegion";
$kac->styleFolder="office2007";
$result = mysqli_query($db_con, "select CountryName from kcb_tbcountries");
while($row = mysqli_fetch_assoc($result))
{
$kac->addItem($row["CountryName"]);
}
$filter_select = "startwith";
if(isset($_POST["filter_select"]))
{
$filter_select = $_POST["filter_select"];
}
$kac->searchFilter=$filter_select;
?>
<form id="form1" method="post">
<div style="float:left;width:300px;margin-bottom:30px;">
<input type="text" id="txtRegion" autocomplete='off' />
<?php echo $kac->Render();?>
</div>
Select filter:
<select id="filter_select" name="filter_select" onchange="submit();">
<option value="startwith" <?php if ($filter_select=="startwith") echo "selected" ?> >StartWith</option>
<option value="contain" <?php if ($filter_select=="contain") echo "selected" ?> >Contain</option>
</select>
<br style="clear:both;"/>
</form>