关于bootstrap typeahead的问题

时间:2015-01-07 08:05:43

标签: php jquery twitter-bootstrap

我们可以在typeahead上绕过撇号吗?

我从数组中的数据库中获取了以下数据:

" 31-Apple"," 53-Apple"," 58-Banana"," 98-Lady's Finger&#34 ;

但显示是

enter image description here

而我需要的是

enter image description here

with(') 我如何设法获得解决方案?

<?php $list=NULL;
    $getcom=mysql_query("select * from tblcommodity order by commodityname");
    while($setcom=mysql_fetch_array($getcom))
    {
        if($list==NULL)
        {
            $comma="";
        }
        else
        {
            $comma=",";
        }
        $list.=$comma."\"".$setcom['commodityid']."-".$setcom['commodityname']."\"";
    }
?>
<input type="text" class="span3" autocomplete="off" style="margin: 0 auto;" data-provide="typeahead" data-items="4" data-source='[<?php echo $list ?>]' name="CommodityID">

1 个答案:

答案 0 :(得分:1)

$('#id').typeahead({
   name: 'Author',
   local: ['12-BalaGuruSwamy', '11-Forouzan', '10-Wayne Tomasi', '9-William Stallings', '8-John C Martin', '7-Robert Lusier']
});

您应该像上面那样将数据库响应传递到本地,您可以实现所需的功能..