javascript array only first character displayed

I’m currently working on a ckeditor plugin, the selectbox gets its data from a DB and I can only get the first character to appear in the selectbox.


  • how to get html from CKEditor?
  • â�� in my html after purify
  • CKEDITOR 4 How to make snapshot before using custom command to use CTRL+Z to undo
  • ckeditor not loading in IE when used in two applications
  • Replace selected content in the ckEditor with new content using javascript
  • ckeditor getData() returning stale data (last change missing) in source mode
  • $query = selectQuery('
        SELECT title, pageID
        FROM  `page_info` 
        WHERE partnerID =?',array($partnerId));
    $test = '';
    foreach ($query as $key => $value) {
    $test .= $value['title'].",";


    var pages = $.post(
            { pid: "1" },
            function(data) {
                return (data);         
    pages = pages.responseText.split(',');

    my variable:

    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"  

    and so on..

    what I do to make my selectbox:

        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.
        else if ( !this.insertMode )
            element.removeAttribute( 'moreinfo' );

    As you can see I simply put the array in the items , but it shows only the first character
    Dialog Block

    So what am I doing wrong?

  • CKEditor embed getting error { “status”: 403, “error”: “valid api_key required” } for https
  • CKeditor - Change table style
  • Ckeditor character limitation with charcount plugin
  • Get computed font size for DOM element in JS
  • get selected html in ckeditor
  • Use “pastefromword” Filtering on All Pasted Content in CKEditor 3
  • 2 Solutions collect form web for “javascript array only first character displayed”

    So, to summarize…

    split() Splits a String object into an array of strings by separating the string into substrings.

    So, presumably your pages.responseText looks like this:

    Home,Control Panel,24/7 Support,Script / Databases,Last Announcment,E-mail: No Limit,Webmail & Push Mail

    Which means that after doing pages = pages.responseText.split(',');, pages looks like this (an array):

    ["Home", "Control Panel", "24/7 Support", "Script / Databases", "Last Announcment", "E-mail: No Limit", "Webmail & Push Mail"]

    According to your previous comment, this works:

    var pages = [{0: 'Home', 1: 'Control Panel', ...}];

    As you can see (an array with multiple values):

    ["Home", "Control Panel", ...]

    is not the same as (an array with one object with several properties):

    [{0: 'Home', 1: 'Control Panel', ...}]

    If all of this is still true, something like this should work:

    var pagesObject = {};
    for (var i=0, max=pages.length; i<max; i += 1) {
      pagesObject[i] = pages[i];
    var correctPages = [ pagesObject ];

    Demo here:

    Based on the for loop of Ayman Sadadi I got it finally right:)

    // page1, 1,00,page2, 12,00,page3, 23 \\
    pages = pages.responseText.split(',00,');
    // ["page1, 1","page2, 12","page3, 23"] \\
    var a = [];
    a[0] = '';
    for (var b = 0; b < pages.length; b++) {
        var c = pages[b].split(', ');
        var pageName = c[0];
        var pageId = c[1];
        a[b] = [ pageName, c ];

    a is now:

    a: Array[31]
      0: Array[2]
        0: "Home"
        1: Array[2]
          0: "Home"
          1: "1"
        length: 2
        __proto__: Array[0]
     1: Array[2]
        0: "Control Panel"
        1: Array[2]
          0: "Control Panel"
          1: "152"
        length: 2
        __proto__: Array[0]

    this is the same as the required [['Home']['Control Panel']].
    If I use that as my items it works correctly.

    previous conversation:

    try to put local data in the select. var pages = [{0: ‘Home’, 1: ‘Control Panel’, …}];. …

    I tryed that 🙂 and it works, but as the pages are constantly added and deleted i can’t hard code the pages in the select

    Ayman Safadi: According to your previous comment, this works…

    Only if I hard code it like [['home']['Control Panel']] it works. [{0: 'Home', 1: 'Control Panel', ...}] did not work. I’m sorry to be a little unclear about what I meant.

    Thank you for helping me with my problem.
    Credits go to Ayman Safadi / pbaris 🙂