Developer forum

Forum » Development » Hiding Div with javascript causes problems..

Hiding Div with javascript causes problems..


Reply

 Ok, so I have a javascript that check for a price of 0€ and hides some divs if the price is 0.
The script is as follows..:

function priceIsZero(price)

{

    var myBoolean = new Boolean(price);

    if(myBoolean == true)

    {

 

        document.getElementById('productDetailsPrice').style.display = "none";

        document.getElementById('productDetailsPriceLabel').style.display = "none";

        document.getElementById('productDetailsOrderBasket').style.display = "none";

    }

}
The first two lines works like a charm, but the last one causes the following error:

 

 

Meddelelse: Et objekt er obligatorisk (an object was expected)

Linje: 165

Tegn: 3

Kode: 0

URI: http://www.dandryer.dk/Default.aspx?ID=267&ProductID=PROD88


I cannot for the life of me figure out why I´m getting that error..
 


Replies

 
Nicolai Høeg Pedersen
Reply
That is because you have your call to priceIsZero(true); before <div id="productDetailsOrderBasket"> is rendered. Place them in the correct order, or wait for dom:loaded.
 
Reply
thank you.
That did it :)

 

You must be logged in to post in the forum