Hi there,
I am trying to make a page which has two input fields, and a submit button. The idea is that input fields are logged into database collection and the page is redirected to new page upon button click. However, once I use both wis-data and wis-location imports and related code, the database collection is not populated.
If I remove the wax-location part, the database logging is good.
Your early help is much appreciated.
Regards,
Spark
Here is the code
import wixloc from ‘wix-location’ ;
import wixData from ‘wix-data’ ;
export function button1_click ( event ) {
if ( $w ( ‘#input1’ ). value . length > 0 && $w ( ‘#input2’ ). value . length > 0 ){
**let** ua = $w ( '#input1' ). value ;
**let** ub = $w ( '#input2' ). value ;
**let** toSave = {
"fa" : ua ,
"fb" : ub };
$w ( '#button1' ). label = "good" ;
wixData . insert ( "mdbase" , toSave )
. then ( ( results ) => {
**let** item = results ;
} )
. **catch** ( ( err ) => {
**let** errorMsg = err ;
} );
wixloc . to ( "red_page" );
}
}