Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Get name of selected RadioButton in Dialog

Avatar

Avatar
Boost 1
Level 1
Hnig
Level 1

Like

1 like

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
Hnig
Level 1

Like

1 like

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
Hnig
Level 1

06-02-2017

Hi everyone,

I'm trying to implement a dialog with a couple of radioButtons in one radioButtonGroup. After pressing "Ok" the selected RadioButton-Name should be displayed in the formular.

I can't figure out a way to get the name of the radioButton and pass it to the form.

Here is what i got so far:

commit: function(dialog) {

     // i need the radio button name here

},

description:{

     name: "Auswahl Schnittstellen",

     elements:[

          {type: "cluster", name: "ABS", elements:[

              {type: "view", align_children: "align_left", elements: [

              {type: "radio", name: "name1", group_id: "rado"},

              {type: "radio", name: "name2", group_id: "rado"},

              {type: "radio", name: "name3", group_id: "rado"},

              {type: "radio", name: "name4", group_id: "rado"},

          ]}

     ]}

]}...

Replies

Avatar

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile
_Bruce_Robertson
MVP

07-02-2017

Hi,

You still need to specify the item_id attribute for the radio buttons, so I would do this like;

function dialog() {

    var descriptor = {

        commit: function(dialog) {

            var elements = dialog.store();

            dialogObject.nam1 = elements["nam1"];

            dialogObject.nam2 = elements["nam2"];

            dialogObject.nam3 = elements["nam3"];

            dialogObject.nam4 = elements["nam4"];

        },

        description:{

         name: "Auswahl Schnittstellen",

         elements:[

              { type: "ok_cancel" },

              { type: "cluster", name: "ABS", elements:[

                  { type: "view", align_children: "align_left", elements: [

                      { type: "radio", name: "name1", group_id: "rado", item_id:"nam1" },

                      { type: "radio", name: "name2", group_id: "rado", item_id:"nam2" },

                      { type: "radio", name: "name3", group_id: "rado", item_id:"nam3" },

                      { type: "radio", name: "name4", group_id: "rado", item_id:"nam4" }]}

            ]}

        ]}

    }

    var dialogObject =

    {

        execDialog: function() { return app.execDialog(descriptor); },

        }; 

    return dialogObject;

}

var d = dialog();

d.execDialog();

console.println(d.nam1);

console.println(d.nam2);

console.println(d.nam3);

console.println(d.nam4);

There will only be one of the four set to true, but it's the item_id that returns the value not the group_id.

Regards

Bruce

Avatar

Avatar
Boost 1
Level 1
Hnig
Level 1

Like

1 like

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
Hnig
Level 1

Like

1 like

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
Hnig
Level 1

09-02-2017

Hi,

First of all, thanks for your solution! But now i have more that 20 radiobuttons, therefore this solution get quiet confusing. I was hoping there was a possibility to return the group_id and read the selected radiobutton out of its information.

I will try to make it work with your solution, but if you find a way to handle it just with the group_id, i would be curious to hear it!

Thanks in advance!

Avatar

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile
_Bruce_Robertson
MVP

11-02-2017

Hi,

I am not aware of a way to do this using the dialog object, though there are a lot of undocumented methods and properties some of which are shown here, Adobe LiveCycle Designer Cookbooks by BR001: execDialog 

But you should be able to get the result you want with a bit of JavaScript;

function dialog() {

    var radioButtonList = [ { type: "radio", name: "name1", group_id: "rado", item_id:"nam1" },

                            { type: "radio", name: "name2", group_id: "rado", item_id:"nam2" },

                            { type: "radio", name: "name3", group_id: "rado", item_id:"nam3" },

                            { type: "radio", name: "name4", group_id: "rado", item_id:"nam4" } ]

    var descriptor = {

        commit: function(dialog) {

            var elements = dialog.store();

            var radioButtonIds = radioButtonList.map(function (entry) { return entry.item_id } )

            for (var i=0, limit=radioButtonIds.length; i < limit; i++) {

                              if (elements[radioButtonIds[i]] == true) {

                 dialogObject.rado = radioButtonIds[i];     

                                   break;

               }

            }

        },

        description:{

         name: "Auswahl Schnittstellen",

         elements:[

              { type: "ok_cancel" },

              { type:"cluster", name: "ABS", elements:[

                  { type: "view", align_children: "align_left", elements: [

                    { type: "static_text", name: "Choose one:" }]

                    .concat(radioButtonList)

                    .concat([ { type: "static_text", name: "some more stuff..." } ])

                }

            ]}

        ]}

    }

    var dialogObject =

    {

        rado: null,

        execDialog: function() { return app.execDialog(descriptor); },

         }; 

     return dialogObject;

}

var d = dialog();

d.execDialog();

console.println(d.rado);

In this example I build up the dialog object with the concat() method, so I can access the item_id in the commit() method.

Regards

Bruce