Hi
I have a nice back end function working that when i select a dropdown box it returns the name of the food in the drop down box and returns the value of the protein associated with that food into a textbook $w(“#protein1Text”).text = $w(“#food1Dropdown”).value .(as shown below)
What ii want to do is add a second return value which is the “measurement” field value in the database and return to another text box. $w(“#measurement1Text”).text = $w(“#food1Dropdown”).value2???
can someone help me out with modifying the below code?
many thanks
Fraser
//Backend code
import wixData from ‘wix-data’;
export function populateDropdownfoodtoprotein(collectionName, protein,) {
let allItems = ;
return wixData.query(collectionName)
.ascending(“foodType”)
.find()
.then((results) => {
if (results.totalCount > 0) {
let items = results.items;
items.forEach((item) => {
let oneItem = {
label: item.foodType,
value: item.protein.toString(),
}
allItems.push(oneItem);
})
return allItems;
}
return null ;
})
}
//Frontend code
import wixData from ‘wix-data’;
import {populateDropdownfoodtoprotein} from ‘backend/utilitiesModule’;
$w.onReady( async function () {
$w(“#food1Dropdown”).options = await populateDropdownfoodtoprotein(“MyFoods”,“protein”,);
});
export function food1Dropdown_change(event) {
$w(“#protein1Text”).text = $w(“#food1Dropdown”).value
//Second return value (not working)
$w(“#measurement1Text”).text = $w(“#food1Dropdown”).value2???
}