I have tried for days now to make this work but still fail so please have a look at this code. expiryDate1 is the name of the field and it isn´t empty but image89 is not collapsing and image77 is not expanding. With other words; the lamp is "off" and dark but shall be flashing (image77 is a gif).
$w.onReady(function () { wixData.get("Members", wixUsers.currentUser.id) const date = $w("#dataset5").getCurrentItem().expiryDate1; wixData.query("Rentingmembers") .eq('expiryDate1') .find() .then( (results) => { if(results.items.length > 0) { console.log("no renting time"); } else { $w("#text424").text = date.toLocaleDateString() $w("#image89").collapse(); $w('#image77').expand(); } })
Just an example.... (in this case the --> _createdDate <-- FIELD was used).
import wixData from 'wix-data'; $w.onReady(()=>{ //wixData.get("Members", wixUsers.currentUser.id); //const date = $w("#dataset5").getCurrentItem().expiryDate1; wixData.query("DATABASE") .isNotEmpty('_createdDate') .find() .then((results)=> { if(results.items.length < 0) {console.log("no renting time");} else {console.log("Data found!!!"); console.log(results.items); let date = results.items[0]._createdDate console.log(date); date = results.items[0]._createdDate.toLocaleDateString() console.log(date); //$w("#text424").text = date.toLocaleDateString() //$w("#image89").collapse(); //$w('#image77').expand(); } }); });
Use a repeater for results and create your ---> "LAMP-FUNCTION" which will show two different states of the lamp --> (IF-ELSE-STATEMENT) inside the RESULTS.