目前,当我在 php 中创建它时,我的预输入看起来像这样
echo '<input type="text" style="margin: 0 auto;" data-provide="typeahead" data-items="4" data-source="[,';
while ( $rowresult = mysql_fetch_assoc($titlequery) ) {
echo '{value:"'.htmlspecialchars($rowresult['title']).'"'."},";
}
echo ']">';
它输出如下:
<input type="text" style="margin: 0 auto;" data-provide="typeahead" data-items="4" data-source="[,{value:"2010-11 Graf Intern"},{value:"2nd Year Finance Explorer, Mizani & L'Oreal Technique"},{value:"A&R Intern"},{value:"Account Executive"},{value:"Account Manager"},{value:"Account Service Representative"},{value:"Account Strategist"},{value:"Accountant"},{value:"Accounting Intern"},{value:"Accounting Intern/Analyst"},{value:"Accounts payable"},{value:"Acquisition Marketing Intern"},{value:"Acquisitions Associate"},{value:"Acting Manager"},{value:"Acting Software Manager"},{value:"Administrator"},{value:"Admissions Ambassador"},]">
不幸的是,它只显示了它能够找到的每个值的第一个字符(值是引导程序的默认值。)
编辑:
问题围绕格式化结果展开,实际上,发生的事情是 Javascript 试图引用一个不存在的数组,因此它采用了元素 [0],它是它的第一个字符。