cancel
Showing results for 
Search instead for 
Did you mean: 

RadioButton select function

venkatachala_ck
Active Participant
0 Kudos

Hi ,

In radio button group i have to get selected value and store it in to x for back-end purpose

i tried using below link

and my code is

in view.xml

  <RadioButtonGroup id="rbgid" columns="1" width="500px" class="sapUiMediumMarginBottom" select="radiobuttonselect">

  <buttons>

                <RadioButton id="RB1" text="Put in process" />              

                <RadioButton id="RB2" text="PostPone"  />

                <RadioButton id="RB3" text="Complete"  />

                <RadioButton id="RB4" text="Delete" />

                          </buttons>

  </RadioButtonGroup>

and in Controller.js

radiobuttonselect: function(evt) {

index = evt.getParameters().selectedIndex;

},

test : function(){

if(index==0)

  {

  var x= sap.ui.getCore().byId("RB1").getSelected().getText();

  alert(x);

  }

  if(index==1)

  {

  var x= sap.ui.getCore().byId("RB2").getSelected().getText();

  alert(x);

  }

if(index==2)

  {

  var x= sap.ui.getCore().byId("RB3").getSelected().getText();

  alert(x);

  }

  if(index==3)

  {

  var x= sap.ui.getCore().byId("RB4").getSelected().getText();

  alert(x);

  }

},

i'm getting error index part.

thanks and regards

Venkat

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Venkatachala,

Will this help? JS Bin - Collaborative JavaScript Debugging

Regards,

Sai Vellanki.

venkatachala_ck
Active Participant
0 Kudos

thanks Sai,

can you correct the above code

my requirement is like that and i don't where i'm doing mistake

saivellanki
Active Contributor
0 Kudos

Hi Venkatachala,

I used your code here. JS Bin - Collaborative JavaScript Debugging


Regards,

Sai Vellanki.

saivellanki
Active Contributor
0 Kudos

I am not sure, where you're calling the test function. No need of writing separate function for it. You can achieve your requirement on Select event only.


Regards,

Sai Veanki.

venkatachala_ck
Active Participant
0 Kudos

Thank you Sai,

Actually i want selected value on click of a button

so only i used one more function and i used one more button in view but i'm not pasted in discussion

saivellanki
Active Contributor
0 Kudos

Hi Venkatachala,

If that is your requirement, why don't you use model concept here? Check this sample: JS Bin - Collaborative JavaScript Debugging

Regards,

Sai Vellanki.

Answers (0)