PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 12/21/2015 10:26 AM by  Randy Jacoy
Error adding span to listbox
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages
mikeP
Private
Private
Veteran Member
(407 points)
Veteran Member
Posts:151


Send Message:

--
12/18/2015 4:05 PM

    I have a Design Studio form where I put a listbox tool on the form.  I have a working DME and have parsed the XML properly and have verified the returned value using alert().

    I followed several helpful examples here, but I can't get the values added to the list box. 

     

    When I run the form directly from IE using a bookmark with ?DEBUG=True appended, the error is "Servlet Express reported: Index record does not exist".  Beyond that, the debug information is not helpful.  Normally I would is the IE F12 debugger examine values and step through javascript code, but portal always shuts the debug window when it starts. 

     

    I've isolated the failure to the appendChild() function, second to last line of code here.  Based on the error, I think maybe I don't have the correct reference to the listbox object on the form, but I tried everything I can think of.

     

    Anyone have any suggestions?

     

    Also, is there a reference for the listbox (and other objects) properties and methods so I can display some of them with alert()?

     

    I looked in the DS Objects Viewer, but it does specifically talk about toolbox object properties. 

     

     

     

        // Assign the DMEs return value to an XML datastorage object
        objXML = new portalWnd.DataStorage(strReturn);

        // Extract the records from the datastorage object to an array
        arrRecs = objXML.document.getElementsByTagName("RECORD");
     
        //var elmListbox = lawform.getElement("lst_fiscal_year");


        //var elmListbox = lawform.getElement("_l13");

        //var elmListbox = document.getElementById("lst_fiscal_year");

        var elmListbox = document.getElementById("_l13");

        //var elmListbox = lawForm.getFormElement("lst_fiscal_year");

        alert("Array count is " + arrRecs.length);

        for (j=0; j < arrRecs.length; j++) {
            arrCols = arrRecs[j].getElementsByTagName("COL");
            alert(arrCols[0].firstChild.data);
            var elmListval = document.createElement("span");
            alert("1")
            elmListval.setAttribute("text","")       
            alert("2")
         elmListval.setAttribute("tran",arrCols[0].firstChild.data)
            alert("3 " + arrCols[0].firstChild.data)
         elmListval.setAttribute("disp",arrCols[0].firstChild.data)
            alert("4 " + arrCols[0].firstChild.data)
            elmListbox.appendChild(elmListval)
            alert("5")
        }

    Randy Jacoy
    Application Developer
    U.S. Bank
    Veteran Member
    (131 points)
    Veteran Member
    Posts:45


    Send Message:

    --
    12/18/2015 4:26 PM
    Mike,

    Try using var elmListbox = lawForm.getElement("VALUES_l13"); to get a reference to your list box values.

    -Randy
    mikeP
    Private
    Private
    Veteran Member
    (407 points)
    Veteran Member
    Posts:151


    Send Message:

    --
    12/21/2015 9:27 AM

    Thanks Randy. That wasn't exactly what it wanted, but it put me on the right track.  This is what worked:

    var elmListbox = document.getElementById("VALUES_l13");

     

    How did you discover this?   The Design Studio guides examples do not include "VALUES", just the field number, e.g. "_l13"

     

     

    Randy Jacoy
    Application Developer
    U.S. Bank
    Veteran Member
    (131 points)
    Veteran Member
    Posts:45


    Send Message:

    --
    12/21/2015 10:26 AM
    Mike, I'm glad you got it working. Honestly I don't remember where I discovered you needed to preface the field ID with VALUES. I know I had a situation where I needed to remove list box values and replace them with something else so I looked at that code to help you with your issue. I probably found the code in this forum. :o).
    You are not authorized to post a reply.