Hide Text in Dynamic Pages When Feild is Null

Hello All,

I’m trying to figure out why my page isn’t working; there are a few different lines of text we want to show depending on whether they are populated or not in the dataset. As far as I can tell, they should work. But for whatever reason, nothing is functioning. Along with the I named the Dataset Signature Series, but it simply does not want to hide anything. Any advice on what I’m missing?

import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;

$w . onReady ( function () {

$w ( “#SignatureSeries” ). onReady ( () => {

/***************/

**let**  adu  =  $w ( "#SignatureSeries" ). getCurrentItem (). adu ; 

**if**  ( adu  ==  ""  ||  adu  ===  **undefined** ){ 
    $w ( '#text185' ). collapse (); 
} 
**else** { 
$w ( '#text185' ). text  =  "ADU:"  +  " "  +  adu ; 

}
/***************/

let fromHomeowner = $w ( “#SignatureSeries” ). getCurrentItem (). homeowner ;
console . log ( fromHomeowner );

**if**  ( fromHomeowner  ===  **undefined**  ||  fromHomeowner  ==  "" ){ 
    $w ( '#descriptiontitle' ). collapse (); 
    $w ( '#text148' ). collapse (); 
} 
**else** { 
    $w ( "#descriptiontitle" ). expand (); 
    $w ( "#text148" ). text  =  fromHomeowner ; 
    } 

/***************/

const matterportimage = $w ( “#SignatureSeries” ). getCurrentItem (). matterportImageUrl ;
const matterportlink = $w ( “#SignatureSeries” ). getCurrentItem (). matterportUrl ;

console . log ( “matterport data” + " " + matterportimage );

if ( matterportimage === undefined ) {
$w ( “#image3” ). collapse ();
$w ( “#text180” ). collapse ();
}
else {
$w ( ‘#image3’ ). src = matterportimage ;
$w ( “#image3” ). link = matterportlink ;
$w ( “#image3” ). target = “_blank” ;

    } 

/***************/

let airbnblink = $w ( “#SignatureSeries” ). getCurrentItem (). airbnbLinnk ;

console . log ( “airbnb link is” + " " + airbnblink );

**if**  ( airbnblink  ==  ""  ||  airbnblink  ===  **undefined** ){ 
    $w ( '#text181' ). collapse (); 
    $w ( '#image4' ). collapse (); 
    
} 
**else** { 
    $w ( '#text181' ). show (); 
    $w ( '#image4' ). link  =  airbnblink ; 
    $w ( '#image4' ). show (); 

} 

/***************/

$w ( “#button15” ). onClick ( ( event ) => {

let name = $w ( ‘#input1’ ). value ;
let number = $w ( ‘#input2’ ). value ;
let email = $w ( ‘#input6’ ). value ;
let question = $w ( ‘#textBox1’ ). value ;

console . log ( name );
console . log ( number );
console . log ( email );

let toInsert = {
“name” : name ,
“phonenumber” : number ,
“question” : question ,
“email” : email
};

wixData . insert ( “CuriousCustomers” , toInsert )
. then ( ( results ) => {
let item = results ; //see item below
console . log ( “items inserted” );
resetform ();

} ) 
. **catch** ( ( err ) => { 
    **let**  errorMsg  =  err ; 
    console . log ( errorMsg ); 
    $w ( '#text184' ). show (); 
    
} ); 

});

function resetform () {
$w ( ‘#text183’ ). show ();
$w ( ‘#input1’ ). value = “” ;
$w ( ‘#input2’ ). value = “” ;
$w ( ‘#input6’ ). value = “” ;
$w ( ‘#textBox1’ ). value = “” ;

    } 

});

Try this one…
And do not forget to use CONSOLE-LOGS for own SITE-DEBUGGING!


import wixData from 'wix-data';
import wixLocation from 'wix-location';

let dataset = [];
    dataset[0] = '#SignatureSeries';

$w.onReady(function () {
    //---------------------------------------------
    $w(dataset[0]).onReady(() => {console.log("Page is READY...");
        let currentItem =  $w(dataset[0]).getCurrentItem(); 
        console.log("Current-Item: ", currentItem);
        let adu = currentItem.adu;
        let fromHomeowner = currentItem.homeowner;
        const matterportimage = currentItem.matterportImageUrl;
        const matterportlink = currentItem.matterportUrl;
        let airbnblink = $w(dataset[0]).getCurrentItem().airbnbLinnk;
        //----------------------------------
        console.log("adu: ", adu);
        console.log("From HomeOwner: ", fromHomeowner);
        console.log("Matterport-Data " + matterportimage);
        console.log("AirBnB link is" + " " + airbnblink);
        //----------------------------------

        //----------------------------------
        if (!adu){$w('#text185').collapse();}
        else{$w('#text185').text = "ADU: " + adu; $w('#text185').expand();}

        //----------------------------------
        if (!fromHomeowner){$w('#descriptiontitle, #text148').collapse();}
        else{
            $w("#descriptiontitle, #text148").expand(); 
            $w("#text148").text = fromHomeowner;
        }
        //----------------------------------
        if (!matterportimage) {$w("#image3, #text180").collapse();}
        else{
            $w('#image3').src = matterportimage;
            $w("#image3").link = matterportlink;
            $w("#image3").target = "_blank";
        }


        if (!airbnblink) {$w('#text181, #image4').collapse();}
        else{$w('#text181, #image4').show(); $w('#image4').link = airbnblink;}


        /***************/
        $w("#button15").onClick((event) => {console.log(event.target.id+"-Clicked");
            let name = $w('#input1').value;         console.log(name);
            let number = $w('#input2').value;       console.log(number);
            let email = $w('#input6').value;        console.log(email);
            let question = $w('#textBox1').value;   console.log(question);

            let toInsert = {
                "name": name,
                "phonenumber": number,
                "question": question,
                "email": email
            };

            wixData.insert("CuriousCustomers", toInsert).then((results) => {
                let item = results; console.log("items inserted: ", item);
                resetform();
            })
            .catch((err) => {console.log(err); $w('#text184').show();});
        });
    });
});


function resetform() {
    $w('#text183').show();
    $w('#input1').value = "";
    $w('#input2').value = "";
    $w('#input6').value = "";
    $w('#textBox1').value = "";
}