Getting Calculated Fields in Code Table


I’ve got a Search Page on my site, when the Calculate button is pressed, the Table appears with the fields based on the search results (see code).
However, I want a number of calculations in the results…
The Price that is displayed in the table, I want to be able to multiply the ‘Number of Adults’ field in the page, I will then do the same with Child and ‘Number of Children’. And then Add the 2 results together.
Also, there is another field in the queried Table (Max Price), so if the calculated total is more than the max price, the max price should be shown.

Is there a way to do this? also, it would be great to display a £ sign in front of the values?

Any help would be great, i’m a newbie to all this!


import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady( function () {

$w("#PriceDetails").columns = [ 
  { 

“id”: “AdultP”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “adultPrice”,
“label”: “Adult Price”, // The column header
“width”: 100, // Column width
“visible”: true , // Column visibility
“type”: “Number”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “”
},
{
“id”: “ChildP”,
“dataPath”: “childPrice”,
“label”: “Child Price”,
“width”: 100,
“visible”: true ,
“type”: “Number”,
“linkPath”: “link-field-or-property”
}
];
});

export function Search_click(event, $w) {
// Runs a query on the “Members” collection
wixData.query(‘Passes’)
// Query the collection for any items whose “Name” field contains
// the value the user entered in the input element
.le(‘startDate’, $w(‘#StartDate’).value)
.gt(‘endDate’, $w(‘#StartDate’).value)
.eq(‘nights’, $w(‘#Nights’).value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w(‘#PriceDetails’).rows = res.items;
$w(‘#PriceDetails’).show();
//$w(‘#BookingResults’).link = “//Bookings/CustomerConfirmation/”& {Booking Ref} ;
//$w(“#ResultBookRef”).value = res.items[1];
//let ResultBookRef = res.items[1];
});
}

Hi David,
There are a lot of threads similar to your request.
Use the search feature on top of the page.
Good luck!
Roi.