Page 1 of 2

Storing radio button selection

Posted: Mon Jun 23, 2014 5:43 pm
by Marco Spera

How can I store the user selection of a radio button?

The radio button is currently being populated from a database list service. I would like to store the users selection from the list.

When I map the radio button to the database, I always get the same radio button selection stored (even if it is different from the one being selected by the user).

Thanks!


Storing radio button selection

Posted: Mon Jun 23, 2014 6:35 pm
by Alena Prykhodko

Hello Marco,

Please give us screen shots of both mappings (one where you populate radio button and other - where you use selected value)


Storing radio button selection

Posted: Mon Jun 23, 2014 7:26 pm
by Marco Spera

Image Image

Here are the two screenshots of populating the radio buttons, and then trying to save the selected radio button to a different collection/database.

Thanks


Storing radio button selection

Posted: Mon Jun 23, 2014 9:19 pm
by Alena Prykhodko

1) First screen shot. Map TeamName to property text as well as to property value of TeamListing element
2) Second screen shot. Map to request parameter Team not from property text of TeamListing element but from property Selected of FullTeamListing element


Storing radio button selection

Posted: Wed Jun 25, 2014 2:03 am
by Marco Spera

Thanks Alena! That worked perfectly!

Can I ask one more questions? How can ensure that the user must select both a radio button option as well as enter an input, before invoking the create service to add to the database?


Storing radio button selection

Posted: Wed Jun 25, 2014 2:36 am
by Yurii Orishchuk

Hi Marko.

That's a validation logic.

Current it could be implemented only with custom JS code.

In this case you should:

1 Remove from your button click event handler with action = invoke create service.

2 Create new JS event handler on the button from 1st step with following code:

pre

//Note: you should replace "inputComponentName" with your input component name.
var yourInputValue = Apperyio("inputComponentName");

//Note you should replace "mobileradiogroup_10" with your mobileradiobuttongroup component name.
var yourRadioButtonValue = Appery("mobileradiogroup_10").find("input:checked").val();

if(yourInputValue && yourRadioButtonValue){
//Here is code if your validation passed.

Code: Select all

 //Note you should replace "yourServiceName" with your datasource create service name on this page. 
 yourServiceName.execute(); 

}
else{
//Here is code if your validation NOT passed.
alert("Something wrong with fields filling..");
};

/pre

Regards.


Storing radio button selection

Posted: Wed Jun 25, 2014 8:49 pm
by Marco Spera

Hi Yurii,

Thanks again. That is almost perfect.

There is only one problem. My radio lists multiple items from a database. If the user inputs a value as well as selects the first radio button, the program proceeds as it should.

But, when the user inputs a value and checks either the 2nd radio button, or 3rd or 4th etc, the app incorrectly displays the error that no radio button was selected.

Why Could this be?


Storing radio button selection

Posted: Wed Jun 25, 2014 10:32 pm
by Marco Spera

Sorry, I think I have figured out the reason (spelling mistake).

Thanks again for all your help.

I have never received such amazing support, I am super thankful!!


Storing radio button selection

Posted: Wed Jun 25, 2014 10:40 pm
by Marco Spera

The radio button works perfectly. The javascript does not seem to recognize if the input value is blank or not. It continuously believes there is something there, when in fact the user leaves it blank.

the JS is below:

var InputValue = Apperyio("SelectionInput");
var RadioButtonValue = Appery("FullTeamListing").find("input:checked").val();

if(InputValue && RadioButtonValue) {
var confirm = alert("Your pick has been entered!");
AddSelection.execute();
}
else {

Code: Select all

 alert("Wrong"); 
 InputValue = ""; 

}


Storing radio button selection

Posted: Wed Jun 25, 2014 10:59 pm
by Marco Spera

Would it be the fact that the JS that you had told me has "apperyio" instead of "appery" and that the variable InputValue does not have .val() at the end?