Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Calculate button

I have three screens: breakfast, lunch and dinner. Each screen has a checkbox list for a food item and their associated carbon units. The users goes through each screen and selects the food items that want. On the dinner screen, I would like to add a calculate button which adds up the carbon units values from all the food items that have been ticked and displays it in a label.

Question: how do I implement this calculate button. Also, how do I pass on data from one screen to the next? is there such thing as hidden form fields?

I have included screenshot of the three screens. Image Image Image

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Calculate button

You can read the values from the page using this simple JavaScript API: http://docs.appery.io/javascript-api/.

To pass values between pages, use local storage.

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Calculate button

Hi,
the values for the checkbox get generated from a database response field.
So I only know the 'name' of one checkbox item. So how do I check which ones out of ALL of them have been selected?

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Calculate button

A further explanation on the original problem would also be appreciated please.

I am new to appery and so am not sure how exactly to assign values to local storage, check whether checkboxes have been selected and if the checkboxes have been selected, I want the corresponding carbonUnits value. Sum up the value at each screen and pass it onto the next screen until it gets to the DinnerScreen and then display the total overall.

Could you please give more help?

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

Calculate button

Hello,

First of all, why you don't use Checkbox group component? That component also can be mapped for arrays.

You need to add event action before you move to another screen. In this action, with JavaScript code you will have to collect all checked inputs and save values to localStorage. As example, please use this link.

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Calculate button

Hi,

I am not able to map the response array to the checkbox group. Not sure why, but that's why I had to map it to the grid.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Calculate button

Here is how to map to check boxes: http://docs.appery.io/documentation/u...

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Calculate button

Yes, as you can see from the screenshot, the array is mapped to a CHECKBOX ITEM and NOT to a checkbox group component as mentioned above by Anton Artyukh.

I can indeed map to a checkbox item but NOT to a checkbox group.

It would be appreciated if the employees could be consistent with their answers.
Thanks

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Calculate button

It was probably just an innocent typo by Anton.

Priyanka Patel
Posts: 0
Joined: Sat Aug 17, 2013 5:41 am

Calculate button

Also, this bears no relevance to my initial question.

I have re-worded the question.
https://getsatisfaction.com/apperyio/...

Could you please answer to this if you can.

Return to “Issues”