Hi All,
I have been looking for this answer for a few days and cannot get a clear answer. It seems to be a recurrent question from lots of users.
I am trying to create the profile for my users and I need to collect their inputs from 2 pages into 1 row of my database. Please see below:
BackEnd Code:
import wixData from ‘wix-data’ ;
let options = {
“suppressAuth” : true ,
“suppressHooks” : true
};
export function dataSubmission ( payload ){
return wixData . insert ( ‘Members’ , payload , options );
}
Code for the first page:
import { dataSubmission } from ‘backend/submission’ ;
import wixLocation from ‘wix-location’ ;
$w . onReady ( function () {
});
export function button8_click ( event ) {
let payload = {
fullName : $w ( ‘#input1’ ). value ,
surname : $w ( ‘#input2’ ). value ,
email : $w ( ‘#input4’ ). value ,
telephone : $w ( ‘#input3’ ). value ,
instagram : $w ( ‘#input5’ ). value ,
profilePicture : $w ( ‘#uploadButton1’ ). value
};
dataSubmission ( payload )
. then ( () =>
{
wixLocation . to ( ‘/physical-profile-and-food-choices’ );
});
}
Code for the second page:
import { dataSubmission } from ‘backend/submission’ ;
import wixLocation from ‘wix-location’ ;
import { local } from ‘wix-storage’ ;
$w . onReady ( function () {
$w ( ‘#texttotal’ ). text = ‘calorias’ ;
$w ( ‘#buttoncontinue’ ). label = ‘Continue’ ;
$w ( '#buttoncontinue' ). onClick (() => {
//$w('#message').text = $w('#weight').value + $w('#height').value;
**let** value = local . getItem ( "key" ); // "value"
**let** inputValue1 = Number ( $w ( "#weight" ). value );
**let** inputValue2 = Number ( $w ( "#height" ). value );
**let** inputValue3 = Number ( $w ( "#age" ). value );
**let** inputValue4 = Number ( $w ( "#dropdown6" ). value );
**let** total = ((( inputValue1 * 10 )+( 6.25 * inputValue2 )-( 5 * inputValue3 ))+ inputValue4 )* 1.375 ;
**if** ( total > 2500 && total < 3000 ) {
**let** total = '2500kcal' ;
} **else if** ( total > 2000 && total < 2500 ) {
**let** total = '2000kcal' ;
} else if ( total > 1500 && total < 2000 ) {
let total = ‘1500kcal’ ;
} else if ( total < 1500 ) {
let total = ‘1000kcal’ ;
} else {
let total = ‘3000kcal’ ;
}
$w ( “#texttotal” ). text = total . toLocaleString ();
let payload = {
objective : $w ( ‘#dropdown2’ ). value ,
gymHome : $w ( ‘#dropdown3’ ). label ,
height : $w ( ‘#height’ ). value ,
weight : $w ( ‘#weight’ ). value ,
age : $w ( ‘#age’ ). value ,
gender : $w ( ‘#dropdown6’ ). label ,
weightGoal : $w ( ‘#input7’ ). value ,
dietType : $w ( ‘#dropdown5’ ). label ,
calories : $w ( ‘#texttotal’ ). text
};
dataSubmission ( payload )
. then ( () =>
{
wixLocation . to ( ‘/profile’ );
}
);
});
});
Any help would be much appreciated