ReadyToLearn
02-29-2008, 05:22 PM
Here is the script I'm working with:
<script type="text/javascript">
<!--
function show(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
function toggle(x){
if(x.src== 'images/plus.gif')
x.src = 'images/minus.gif';
else
x.src = 'images/plus.gif';
}
//-->
</script>
Each of these functions works independently (well, kind of).
1. I'd like to combine these two. Bascially, when a div is showing (display:block) i'd like for the image to be minus.gif and of course the opposite to be true.
2. The toggle function only works once. The image is initially minus.gif. When I click it it turns to plus.gif but when I click it again it doesn't change. If I initially use plus.gif, it doesn't work at all.
these are both onClick events on the image itself. In the case of the latter (toggle) function, I'm using "this" whereas in the show function i'm using the id of the div.
Thanks for the help :)
<script type="text/javascript">
<!--
function show(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
function toggle(x){
if(x.src== 'images/plus.gif')
x.src = 'images/minus.gif';
else
x.src = 'images/plus.gif';
}
//-->
</script>
Each of these functions works independently (well, kind of).
1. I'd like to combine these two. Bascially, when a div is showing (display:block) i'd like for the image to be minus.gif and of course the opposite to be true.
2. The toggle function only works once. The image is initially minus.gif. When I click it it turns to plus.gif but when I click it again it doesn't change. If I initially use plus.gif, it doesn't work at all.
these are both onClick events on the image itself. In the case of the latter (toggle) function, I'm using "this" whereas in the show function i'm using the id of the div.
Thanks for the help :)