Customised Calculator from Sandbox to a Webpage

Hi all,

I want to make a webpage shows a calculated result from my web page.

It is a series of YES or NO with radion button, and the result is submitted to a database in Sandbox.

In the backend, I set each option with a different value. Although the visitor sees YES or NO on the page, I see the value instead in Sandbox. For example, a YES scores 15, a NO scores 0.

Once the user submits the answer, it will take them to a result page with a score which is calculated based on the options they selected: The total score they’ve got.

In this case, is the Hook js is AfterQuery or AfterUpdate?

I am thinking I can use the same logic as adding items into the shopping cart and it shows the total amount.


A sample from Vorbly :
export function quantity1_change(event, $w) {
let price = Number($w(‘#UnitPrice1’).text);
let selectedQuantity = Number(event.target.value);
$w(‘#FinalPrice1’).text = String(selectedQuantity * price);
$w(‘#TotalPrice’).text = String(Number($w(‘#FinalPrice1’).text) + Number($w(‘#FinalPrice2’).text));
}

export function quantity2_change(event, $w) {
let price = Number($w(‘#UnitPrice2’).text);
let selectedQuantity = Number(event.target.value);
$w(‘#FinalPrice2’).text = String(selectedQuantity * price);
$w(‘#TotalPrice’).text = String(Number($w(‘#FinalPrice1’).text) + Number($w(‘#FinalPrice2’).text));
}

I’m new to the coding, I know how to do the calculating coding, but I get a bit confused about how can I pull the data from my data collection in the sandbox, calculate, and show the result on my result page?

Thank you!