KoolComboBox supports loading options on-demand, the typed text of user to KoolComboBox will be sent back to server, server will query database for the list options which are close to what user typed.
This feature is very helpful when you have a large list of option for user to choose. Loading options on-demand will be best solution to boost performance of page.
<?php
require $KoolControlsFolder."/KoolComboBox/koolcombobox.php";
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$kcb = new KoolComboBox("kcb");
$kcb->scriptFolder = $KoolControlsFolder."/KoolComboBox";
$kcb->itemTemplate = "<table><tr><td valign='middle' style='width:22px;height:20px;'><img src='../../Resources/Flags/{flagimage}' alt='{text}' title='{text}' /></td><td valign='middle'>{text}</td></tr></table>";
$kcb->width = "200px";
$kcb->styleFolder="inox";
function funcService($text)
{
$db_con = $GLOBALS["db_con"];
$itemlist = array();
$result = mysqli_query($db_con, "select CountryID,CountryName,FlagImage from kcb_tbcountries where CountryName LIKE '$text%';");
while($row = mysqli_fetch_assoc($result))
{
$item = array("text"=>$row["CountryName"],"value"=>$row["CountryID"],"flagimage"=>$row["FlagImage"]);
array_push($itemlist,$item);
}
return $itemlist;
}
$koolajax->enableFunction("funcService");
$kcb->serviceFunction = "funcService";
?>
<form id="form1" method="post">
<?php echo $koolajax->Render();?>
<div style="padding-left:10px;padding-bottom:10px;">
Choose a nation:
</div>
<div style="padding-left:10px;padding-bottom:50px;">
<?php echo $kcb->Render();?>
</div>
</form>