Jump to content

Changing values and display...


rendezvous123

Recommended Posts

This is what i currently have for the JavaScript script.
[code]function switch(id, id2, id3){

if (document.getElementById){
var obj = document.getElementById(id);
var obj2 = document.getElementById(id2);
var obj3 = document.getElementById(id3);
if (obj2.style.display == "none") {
obj.value = "Switch to Content Mode";
obj2.style.display = "block";
obj3.style.display = "none";
} else {
obj.value = "Switch to Shout Mode";
obj2.style.display = "none";
obj3.style.display = "block";
}
}

}[/code]

I've been trying to test it using this:
[code]<input id="displayer" type="button" value="Switch to Shout Mode" onclick="switch('displayer', 'n1', 'n2')"/>
<div id="n1" style="display: none;">Shout!</div>
<div id="n2">Content!</div>[/code]

When i click on the button, i want the button's value to change, and the display of both DIV elements to switch. But whenever i click the button, nothing happens. I can't see anything wrong with the script.  But, then again, i'm not a JavaScript person. Any help would be appreciated. :D
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.