Hi All, I’m really hoping someone can help me please. I’ve spent most of the night scouting this forum and youtube/google for a solution.
Essentially in the below diagram changing the id in the flight-platform dropdown (my Primary key “ID” Field updates the info on the page from a data set.
What I am trying to do is have the user be able to change the “Reps” in the text box then when they press the button (Not fully sure why I made this an eyeball but it was 3AM), this multiplies the “Reps” Value by the “Coef” value and applies the result to the “Points Value”. This then should update the collection with new “Reps” & “Points” Value. For some reason when I was running the code last nigh it was updating the collection with the reps but not doing the multiplication. Now when I run the code in preview it does absolutely nothing.
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
const mycollection = “liftscores” ;
const updateitem =()=>{
let reps = Number ( $w ( ‘#Coeftext’ ). text );
let coef = Number ( $w ( ‘#Repsinput’ ). value );
$w ( ‘#PointsText’ ). text = String ( reps * coef )
let toUpdate = {
“_id” : $w ( “#FPDropdown” ). value ,
“reps” : $w ( “#Repsinput” ). value
};
wixData . update ( mycollection , toUpdate )
. then (( results ) => {
console . log ( results ); //see item below
})
. catch (( err ) => {
console . log ( err );
});
}
$w ( “#SubmitButton” ). onClick ( updateitem )
}
// …
