I have searched and searched over so many previously answered questions and to my surprise, NONE of them answer what I am trying to accomplish. with JQuery this is easy but I am struggling with strict javascript.
I cannot have any embedded JS OR CSS in the html...
This is what I have so far:
function showhide()
{
var billingaddress = document.getElementById("billingaddress");
if (billingaddress.style.display === "block")
{
billingaddress.style.display = "none";
}
else if (billingaddress.style.display === "none")
{
billingaddress.style.display = "block";
}
}
function init ()
{
var billingcheckbox = document.getElementById("billing");
if (billingcheckbox.checked)
{
showhide();
}
else
{
showhide();
}
It is hidden by default using CSS.
Cheers,
billingaddressis a waste. Instead pass it as a parameter toshowhide.initfunction missing a closing brace.