I tend to write my javascript as big blocks of code without many variable or functions but have decided to clean up my act! Below is an attempt at writing a cleaner version of a script that hides certain form elements depending on the value of a drop down box.
The script worked perfectly before I tried to tidy it up but now I cannot see where the problem is? Could anyone advise me of any problems with my syntax here. Apologies for the very specific post.
Thanks,
Rich
function hideTitle(hide){
if(hide = "true"){
document.admin.title.style.display="none";
document.getElementById("titleText").style.display="none";
};
else if(hide = "false"){
document.admin.title.style.display="inline";
document.getElementById("titleText").style.display="inline";
};
};
function hideSocMedLinks(hide){
if(hide = "true"){
document.admin.facebookLink.style.display="none";
document.admin.twitterLink.style.display="none";
document.getElementById("fbtext").style.display="none";
document.getElementById("twittext").style.display="none";
};
else if(hide = "false"){
document.admin.facebookLink.style.display="block";
document.admin.twitterLink.style.display="block";
document.getElementById("fbtext").style.display="inline";
document.getElementById("twittext").style.display="inline";
};
};
function hideWebLink(hide){
if(hide = "true"){
document.admin.webLink.style.display="none";
document.getElementById("webtext").style.display="none";
};
else if(hide = "false"){
document.admin.webLink.style.display="block";
document.getElementById("webtext").style.display="inline";
};
};
function toggleFormElements(){
if(document.admin.pageType.options[document.admin.pageType.selectedIndex].value == "homePage"){
hideTitle("true");
hideSocMedLinks("true");
hideWebLink("true");
};
else if(document.admin.pageType.options[document.admin.pageType.selectedIndex].value == "socialMedia"){
hideTitle("false");
hideSocMedLinks("false");
hideWebLink("true");
};
else if(document.admin.pageType.options[document.admin.pageType.selectedIndex].value == "webDesign"){
hideTitle("false");
hideSocMedLinks("true");
hideWebLink("false");
};
};