Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Storing radio button selection

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!

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Storing radio button selection

Hello Marco,

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

Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Storing radio button selection

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Storing radio button selection

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

Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Storing radio button selection

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?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Storing radio button selection

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.

Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Storing radio button selection

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?

Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Storing radio button selection

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!!

Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Storing radio button selection

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 = ""; 

}

Marco Spera
Posts: 0
Joined: Tue Jun 17, 2014 7:14 pm

Storing radio button selection

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?

Return to “Issues”