Expand my Community achievements bar.

Unable to get three dropdowns to autopopulate

Avatar

Level 2

I have three dropdowns that I need to autopopulate and it won't work.  When using the JavaScript Debugger I can see that it says "TypeError:... is not a function" but not sure how to fix.

The Three dropdowns are called:

     ddlIncidentLoc

     ddlIncidentArea

     ddlIncidentSubArea

Here is the code:

form1.#subform[0].#variables[0].asaScript - (JavaScript, client)

var g_ArrayOfficeInfo = new Array(

    new Array("Market Tower", new Array("Reception area", "Desk", "Interview booth", "Waiting room", "Telephone", "E-mail", "Other: ")),

    new Array("GCCRC", new Array("Reception area", "Desk", "Interview booth", "Waiting room", "Telephone", "E-mail", "Other: ")),

    new Array("SLNRC", new Array("Reception area", "Desk", "Interview booth", "Waiting room", "Telephone", "E-mail", "Other: ")),

    new Array("LUSO", new Array("Reception area", "Desk", "Interview booth", "Waiting room", "Telephone", "E-mail", "Other: ")),

    new Array("NE", new Array("Reception area", "Desk", "Interview booth", "Waiting room", "Telephone", "E-mail", "Other: "))

);                             

var g_ArrayFieldInfo = new Array(

    new Array("Home visit", new Array("Name:")),

    new Array("Shelter", new Array("Name:")),

    new Array("Hospital", new Array("Name:")),

new Array("Court House", new Array("Name:")),

new Array("Provincial Offences Office", new Array("Name:")),

new Array("Purchase of Service Agency", new Array("Name:")),

new Array("Other:", new Array("Name:"))

);

var g_ArrayPublicInfo = new Array(Specify:”);

var g_ArrayLocInfo = new Array(g_ArrayOfficeInfo, g_ArrayFieldInfo, g_ArrayPublicInfo);

function updateAreas(objDropDown, nLocIndex)

{

    var arrayLocInfo = g_ArrayLocInfo[nLocIndex];

    for (var i=0; i<arrayLocInfo.length; i++)

    {

        objDropDown.addItem(arrayLocInfo[i][0], String(i));

    }

}

function updateSubAreas(objDropDown, nLocIndex, nAreaIndex)

{

    var arrayLocInfo = g_ArrayLocInfo[nLocIndex];

    var arrayAreasSubAreas = arrayLocInfo[nAreaIndex][1];

    for (var i=0; i<arrayAreasSubAreas.length; i++)

    {

        objDropDown.addItem(arrayAreasSubAreas[i], String(i));

    }

}

form1.#subform[0].ddlIncidentLoc::change - (JavaScript, client)

if (this.rawValue != xfa.event.newText)

{

    ddlIncidentArea.rawValue = "";

    ddlIncidentArea.clearItems();

    ddlIncidentSubArea.rawValue = "";

    ddlIncidentSubArea.clearItems();

    asaScript.updateAreas(ddlIncidentArea, this.boundItem(xfa.event.newText));

}

form1.#subform[0].ddlIncidentArea::change - (JavaScript, client)

if (this.rawValue != xfa.event.newText)

{

    ddlIncidentSubArea.rawValue = "";

    ddlIncidentSubArea.clearItems();

    asaScript.updateSubAreas(ddlIncidentSubArea, ddlIncidentLoc.rawValue, this.boundItem(xfa.event.newText));

}

4 Replies

Avatar

Level 5
  • I would start by renaming your fields to remove the # sign in the name of the form fields. form1.#subform[0].#variables[0].asaScript would become somthing like form1.presubform.tempVariables.asaScirpt
  • I am not certain but in the past I have encountered problems in LiveCycle with functions that contain capitalizations in the function name. You might try changing the name to all lower case. I'm not completely certain this is illegal however in function naming.
  • Typically the console error "Not a function" means LiveCycle is not finding the function you are calling. I see that you created two functions in form1.#subform[0].#variables[0].asaScript - (JavaScript, client) however these are called outside of that form field. This would ceratainly be a problem.
  • Can you post your form for a better look in Adobe Workspaces or another link?

Hope that helps.

Avatar

Level 2

I just tested and link works for me.  Also, I just got it working by deleting and retyping the quotes around 'Specify: '.  Go figure!