dongwaner1367 2013-03-22 07:08
浏览 5

如何识别元素是否在自动完成中?

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 . "
";

        }
    }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大