我目前正在研究一个ckeditor插件,selectbox从数据库获取它的数据,我只能得到第一个字符出现在选择框中。javascript array只显示第一个字符
get_pages.php
$query = selectQuery('
SELECT title, pageID
FROM `page_info`
WHERE partnerID =?',array($partnerId));
$test = '';
foreach ($query as $key => $value) {
$test .= $value['title'].",";
}
Plugin.js
var pages = $.post(
"/action/ac_select_pages.php",
{ pid: "1" },
function(data) {
return (data);
}
);
pages = pages.responseText.split(',');
我的变量:
pages: Array[31]
0: "Home"
1: "Control Panel"
2: "24/7 Support"
3: "Script/Databases"
4: "Last Announcment"
5: "E-mail: No Limit"
6: "Webmail & Push Mail"
等..
什么我让我的选择框:
{
type : 'select',
id : 'moreinfo',
label : 'Meerinfo Link',
style : 'width:300px;',
items : pages ,
setup : function(element)
{
this.setValue(element.getAttribute("moreinfo"));
},
commit : function(element)
{
var id = this.getValue();
// If the field is non-empty, use its value to set the element's id attribute.
if (id)
element.setAttribute('moreinfo', id);
// If on editing the value was removed by the user, the id attribute needs to be removed.
// http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom.element.html#removeAttribute
else if (!this.insertMode)
element.removeAttribute('moreinfo');
}
}
正如你可以看到我简单地把数组中的项目,但它显示的第一个字符
那我做错了吗?
你能提供更多的代码 – cIph3r 2013-02-18 15:00:57
如何生成下拉菜单?你可能像字符串一样处理字符串。 – 2013-02-18 15:02:42
@ clph3r更多信息按要求提供。 @RocketHazmat从数据库获取这样的'第1页,第2页,page3' 分裂,使阵列 组阵列作为项目 所以让我打的页面阵列它是工作,但是当我说'项目:pages'它只是变得第一个字符。它将第二个字符视为选项值:S – 2013-02-18 15:13:40