I deleted my old post as I have made progress, and the old post was a little dumb on my part.
Site with form.
https://braphox.wixsite.com/website/form
I have made some progress so I have edited the question.
I am having issues updating a database from a form.
CurrentRP ; input1
RPGoal: input2
So far only CurrentRP is updating.
Additionally, I would like to declare a new variable RPLeft and use the math function to find RPGoal-CurrentRP.
// For full API documentation, including code examples, visit http://wix.to/94BuAAs //TODO: write your code here...=RPGoal-CurrentRP
import wixData from 'wix-data'; export function button1_click(event, $w) { let toInsert = { "CurrentRP": $w("#input1").value , "RPGoal": $w("input2").value }; //let "x"= {$w("#input1").value, //"y"=$w("#input2").value, //"z"=(Math.round(y-x))} wixData.insert("FormEnterRP", toInsert) .then( (results) => { let item = results; } ) .catch( (err) => { let errorMsg = err; })}
Thank You
It looks like a missing # sign
$w("#input1").value , "RPGoal": $w("[here]input2").value }; //let "x"= {$w("#input1").value, //"y"=$w("#input2").value
I have the inputs now being sent to the dabase. Now I am just having issues with the calculation and passing the calculated value to the database.
Any thoughts? Anyone?
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
//TODO: write your code here...=RPGoal-CurrentRP import wixData from 'wix-data'; export function button1_click(event, $w) { var begin = $w("#input1"); var end = $w("#input2"); var difference = (Math.round(end-begin)); $w("#difference") = difference; <-- Parsing error assigning to rvalue let toInsert = { "CurrentRP": $w("#input1").value , "RPGoal": $w("#input2").value, "RPLeft": $w("#difference").value, <-- here difference is not a valid selector error }; wixData.insert("FormEnterRP", toInsert) .then( (results) => { let item = results; } ) .catch( (err) => { let errorMsg = err; })} export function page1_click(event, $w) { //Add your code for this event here: }
I got it to work I think I was thinking it had to be harder than it was.
I did notice that these columns are added to the database as new columns.
// For full API documentation, including code examples, visit http://wix.to/94BuAAs //TODO: write your code here...=RPGoal-CurrentRP import wixData from 'wix-data'; export function button1_click(event, $w) { //the buttton on the page is not connected to the database let toInsert = { "CurrentRP": $w("#input1").value , "RPGoal": $w("#input2").value, "RPLeft": $w("#input2").value-$w("#input1").value , //<-- I was convinced I needed to use (math.round(... }; wixData.insert("FormEnterRP", toInsert) .then( (results) => { let item = results; } ) .catch( (err) => { let errorMsg = err; })} export function page1_click(event, $w) { //Add your code for this event here: }