Button Add Function

Hello,
I have a language center where students top up there cards to visit classes, now I have a button and an input filed of number in the dynamic page. the button has the label “Top Up For 12 Lessons”. When I press this button I want to add the sum 12 to the number the filed has. For example. The student has 6classes remaining but he wants to top up the card, I press the button “Top Up For 12 Lessons” and it adds 12 to the number 6. So I get 12+6=18
I don’t need the button to save the dataset, I just need to add the sum.
How can I have this work with an onClick event?
Please can someone give me the code for this?
Thanks in advance!

Hi,

First, you should get the value of that field for that student, check THIS for more information.
Second, add that value you get to 12 . For example :

let sum = results.numOfClasses + 12 ; 

and then you can save the sum or use it where you want.

hope this helps!
Best,
Mustafa

Dear Mustafa, Thank you for your help. I have tried your code, but I can not make it work. Please, if it is possible, can you give me the code for this?

Hi,
Can you please share the code you have tried? so we could fix it.

Hello Dear Mustafa,
Here is My code. Please check it. Thanks in advance.

export function c12_click(event) {
 let numOfRemaining = ("#Remaining").value
    .then( () => {
    get.("#Remaining").value
 let sum = results.numOfRemaining + 12
}

This code will not work. Few things you should know :
1- At first you should get the user id, so you know which user you will get the value of Remaining from.
2- That’s no the right way to use .get , please read this Api carefully - Here

so basically, what you should do is :
1- get user id - Help!
2- get the data from the field you want - named as remaining .
3- add 12 to the value you get from step #2.

OMG, I am trying it so hard, but I can not make it work. Please help me with this. I will be very glad.