Hello everybody,
with a button click function i would like to do that on my database:
1- read a text input word and load into a variable…WORKING
2- query if in my database is present an item with that name ad if is not present insert it…WORKING
3- save one or more text input inside the just created element’s fields…NOT WORKING
thanks in advance
export function Newprogram_click ( event ) {
let programname = $w ( “#Newprogramname” ). value ;
wixData . query ( “Programs” )
. eq ( ‘nomeprogram’ , programname )
. find ()
. then (( results ) => {
if ( results . items . length === 0 ) {
**const** toInsert = {
"nomeprogram" : programname ,
}
wixData . insert ( "Programs" , toInsert )
}
})
$w ( "#Programsdataset" ). setFilter ( wixData . filter ()
. eq ( 'nomeprogram' , programname )
);
**let** day1es1 = $w ( "#day1Es1" ). value ;
$w ( "#Programsdataset" ). setFieldValues ({
"day1Es1" : day1es1 ,
"day2Es1" : day1es1 ,
});
$w ( "#Programsdataset" ). save ();
}