cancel
Showing results for 
Search instead for 
Did you mean: 

get selected radio button value on form onclick

0 Kudos

Hi All,

    I have a three radio button which is in form. I want to get the selected radio button values while submit a form. How to do this? I have mentioned my code below. Any help would be greatly appreciated.


var oform = new sap.ui.layout.form.SimpleForm("f1",{

  maxContainerCols:4,

  editable:true,

  content:[

          new sap.ui.commons.RadioButtonGroup({

          columns:4,

          items:[new sap.ui.core.Item({text:"radio1"}),

                 new sap.ui.core.Item({text:"radio2"}),

                 new sap.ui.core.Item({text:"radio3"})

                 ]

          }),

          new sap.ui.commons.Button("b1",{

          text:"Submit",

          width:"100px",

          press:function(){         

          var selItem = sap.ui.core.Item.getSelectedItem(); // Need to get selected radio button values

         

          }

          })

          ]

  });

  oform.placeAt("content");

Accepted Solutions (1)

Accepted Solutions (1)

santhu_gowdaz
Active Contributor
0 Kudos

if you want to get text,

oRBG2.getSelectedItem().getText());

2nd example of this link RadioButtonGroup - SAPUI5 Demo Kit

Answers (2)

Answers (2)

former_member182862
Active Contributor

what about this way?

sample

-D

sandroramos
Active Participant

Hi,

Try selectedIndex property or getSelectedButton method of Radio Button Group component to return selected item.

Regards,

Sandro Ramos