【发布时间】:2016-04-17 20:27:09
【问题描述】:
这是我的 Javascript 的一部分:
$(function(){
var dbTags=<?php echo json_encode($namesArray);?>;
var myTag;
$("#searchTags").autocomplete({
source: dbTags,
minLength: 2,
select: function(event, ui){
myTag=ui.item.value;
我的php代码:
$findNames=$user_home->runQuery("SELECT productTitle, category from Iranga ");
$findNames->execute();
$information=$findNames->fetchAll(PDO::FETCH_ASSOC);
foreach($information as $item){
$namesArray=array("label:"=>$item['productTitle'], "category:"=>$item['category']);
}
我打算使用这个脚本: https://jqueryui.com/autocomplete/#categories
问题如何使用和定义我的dbTags 变量,当它包含产品类型和类别时?
【问题讨论】:
标签: javascript php jquery-ui autocomplete