Error adding span to listbox

 3 Replies
 1 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
mikeP
Veteran Member
Posts: 151
Veteran Member

    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
    Veteran Member
    Posts: 46
    Veteran Member
      Mike,

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

      -Randy
      mikeP
      Veteran Member
      Posts: 151
      Veteran Member

        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
        Veteran Member
        Posts: 46
        Veteran Member
          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).