I am using PHP with JS. I am doing an autocomplete of items in a text box. free text is also enabled in this text box.I need to check whether this entry is a free text or not. I.e, I need to check whether the entered text box value is equal to one of the element got by the output of the action passed to the controller
Here is my JS(Jquery autocomplete) code:
$("#txtVmVehicleNumber").autocomplete('/business_vehicle/getItems', {
minChars: 1,
matchContains: "word",
autoFill: true,
max:100,
multiple :false,
mustMatch : false,
});
Here, you can see that must match is made as false,so that we can make free text in this entry in such way, if we are free texting and doing a tab,this should say that this element is not in the array.
Here is my PHP code:
public function getItemsAction() {
$this->_helper->viewRenderer->setNoRender();
//Creating object for Request
$objRequest = $this->getRequest();
//take parameters from http request
$strSearchKey = $objRequest->getParam('q');
//Creating object Request
$objLib= new lib_Business_items();
$rstItems = $objLib->getItemsAutoComplete($strSearchKey);
if (count($rstItems) != 0) {
foreach ($rstItems as $objItems) {
echo $objItems->vchr_item . "
";
}
}
}