Soldato
- Joined
- 6 Dec 2002
- Posts
- 3,400
- Location
- North East
I'm trying to work out why it won't allow the same thing but a different way.
I'm trying to build up so that I have a function or a set of functions that allow a set of div's to appear and disappear.
i.e.
You click on A
A appears
You click on B
A disappears, B appears
This works:
div.show { display: block; background-color: blue; }
function showhide2 (id, className) {
document.getElementById (id).className = className;
}
<a href="#" onclick="showhide2 ('div1', 'show');" >Hide 1</a>
However...
I tried to move onto step 2 of creating this idea and it broke
<a href="#" onclick="showhide ('div1');">A</a>
var state = 'show';
function showhide (id) {
document.getElementById (id).state = state;
}
I can't understand whats different from passing the word show from the link or getting it from the variable state.
Any help greatly appreciated!
BeatMaster
I'm trying to build up so that I have a function or a set of functions that allow a set of div's to appear and disappear.
i.e.
You click on A
A appears
You click on B
A disappears, B appears
This works:
div.show { display: block; background-color: blue; }
function showhide2 (id, className) {
document.getElementById (id).className = className;
}
<a href="#" onclick="showhide2 ('div1', 'show');" >Hide 1</a>
However...
I tried to move onto step 2 of creating this idea and it broke

<a href="#" onclick="showhide ('div1');">A</a>
var state = 'show';
function showhide (id) {
document.getElementById (id).state = state;
}
I can't understand whats different from passing the word show from the link or getting it from the variable state.
Any help greatly appreciated!

BeatMaster
