Also, please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.
You can go back and change your post to add code tags by clicking the .
I don't know what exactly you are trying to do. I guess you wish to show/hide the div based on the input selected in the select box(Please correct me if I'm wrong).
If the case as above, then you can simply use the visiblity parameter of style attribute of <div> as ---
Yes, definitely it won't enter the if block because it does not return the value you are comparing in the if statement.
If you put an alert before if as shown you will easily come to know what is the value here's the code:
function show(tabName) { //Add this line and you will come to know why it is not working //alert(document.getElementById(tabName).style.display); if(document.getElementById(tabName).style.display == "none") { document.getElementById(tabName).style.display = "block"; } else if(document.getElementById(tabName).style.display == "block") { document.getElementById(tabName).style.display = "none"; } }
Oops!!! Sorry!! Just a correction in previous post's code Uncomment the alert line
function show(tabName) { //Add this line and you will come to know why it is not working alert(document.getElementById(tabName).style.display); if(document.getElementById(tabName).style.display == "none") { document.getElementById(tabName).style.display = "block"; } else if(document.getElementById(tabName).style.display == "block") { document.getElementById(tabName).style.display = "none"; } }
No holds barred. And no bars holed. Except this tiny ad: