Expand my Community achievements bar.

For Loop in execDialog Description

Avatar

Level 2

Hi all,

I am using the Javascript execDialog function to create a dynamic popup to get some information from the user.  I have an array defined before the dialog and I need to be able to create a row that contains a checkbox and text area for each item in the array.  I'm not sure how I would/if I can use a for loop to do this.  I placed a For Loop around the entire thing but, of course, I end up getting one dialog box per array item which is not what I want.  I want a total of one dialog box with a variable number of rows.  Here's my code currently.  The area in red is what I need to perform the loop on and have it repeat for each element in my other array.  Please help - this is urgent!

var fundsDialog = {

description: {

     name: "Verify Current Info",

     elements:

          [

          {

               type: "cluster",

               align_children: "align_left",

               elements:

               [

                    {

                         item_id:"main_text1",

                         type: "static_text",

                         name: "You indicated the following...",

                         bold: true,

                         font: "dialog",

                         char_width: 30,

                         height: 20,

                    },

                    {

                         item_id:"main_text2",

                         type: "static_text",

                         name: "Name goes here",

                         bold: true,

                         font: "dialog",

                         char_width: 30,

                         height: 20,

                    },

                    {

                         item_id:"main_text3",

                         type: "static_text",

                         name: "Please confirm the below items exist and uncheck any that don't apply.",

                         bold: true,

                         font: "dialog",

                         char_width: 30,

                         height: 20,

                    },

                    {

                         type: "view",

                         align_children: "align_row",

                         elements:

                         [

                              {

                                   item_id:"box1",

                                   type: "check_box",

                                   //char_width: 30,

                                   height: 15,

                                   multiline: true,

                              },

                              {

                                   item_id:"text1",

                                   type: "static_text",

                                   name: itemToShow,

                                   font: "dialog",

                                   char_width: 30,

                                   height: 100,

                              }

                         ]

                    },

                    {

                         type: "ok"

                    }

               ]

          }

          ]

     }

};

1 Reply

Avatar

Level 10

Hi,

You can pass in an array of dialog elements, so if you can build that up an array before the execDialog object.  Something like;

var o1 = [];

o1.push({

            item_id: "box1",

            type: "check_box",

            //char_width: 30,

            height: 15,

            multiline: true,

        },

        {

            item_id: "text1",

            type: "static_text",

            name: "Item 1",

            font: "dialog",

            char_width: 30,

            height: 100,

        });

o1.push({

            item_id: "box2",

            type: "check_box",

            //char_width: 30,

            height: 15,

            multiline: true,

        },

        {

            item_id: "text2",

            type: "static_text",

            name: "Item 2",

            font: "dialog",

            char_width: 30,

            height: 100,

        });    

var fundsDialog = {

description: {

     name: "Verify Current Info",

     elements:

          [

          {

               type: "cluster",

               align_children: "align_left",

               elements:

               [

                    {

                         item_id:"main_text1",

                         type: "static_text",

                         name: "You indicated the following...",

                         bold: true,

                         font: "dialog",

                         char_width: 30,

                         height: 20,

                    },

                    {

                         item_id:"main_text2",

                         type: "static_text",

                         name: "Name goes here",

                         bold: true,

                         font: "dialog",

                         char_width: 30,

                         height: 20,

                    },

                    {

                         item_id:"main_text3",

                         type: "static_text",

                         name: "Please confirm the below items exist and uncheck any that don't apply.",

                         bold: true,

                         font: "dialog",

                         char_width: 30,

                         height: 20,

                    },

                    {

                         type: "view",

                         align_children: "align_row",

                         elements: o1

                    },

                    {

                         type: "ok"

                    }

               ]

          }

          ]

     }

};

Does that help?

Bruce