@alan33921 I completely understand process, the calculation needs to be set on the dataset’s onBeforeSave() event handler, create a dynamic event in the page’s onReady() function like this, and place the code inside it.
‘Enter virtual results’ Page:
$w.onReady(() => {
$w('#dataset').onBeforeSave(() => {
let value = { raw: '', hr: '', min: '', sec: '' };
value.hr = Number($w('#hours').value);
value.min = Number($w('#minutes').value);
value.sec = Number($w('#seconds').value);
let result = (value.hr*60*60) + (value.min*60) + value.sec;
$w('#dataset').setFieldValue({searchBar: result});
})
})
‘My virtual results’ Page
let tableData = [];
await wixData.query('collection').find().then((result) => {
if (result.length > 0) {
result.items.forEach(item => {
let time = item.time;
let sec = time % 60
let min = ((time-sec) % (60 * 60)) / 60;
let hr = (time - sec - (min*60)) / (60 * 60);
let item = {
state: item.state,
distance: item.distance,
time: `${hr}:${min}:${sec}`
}
tableData.push(item);
})
}
})
if (tableData.length > 0) {
$w('#table').rows = tableData;
}
Unfortunately, there’s no way you can achieve this using the dataset, you’ll need to use query and data-binding as shown above.
The blue keywords are the columns’ IDs, modify them accordingly.