Hi,
I am really new to javascript so dont blame me please.
I tried to perform a Spoiler, which went actually pretty good:
This is yet very undynamic.
However, I tried to add extra functionality: close all other spoilers when opening one.
I tried with a while which should close all spoilers, before opening a new one.
I changed the script to this, using a fixed value for the while because I have no idea how to count document.getele mentbyid elements :S
And at this point, I have no more access to my spoilers, they wont open at all :/
Since javascript offers no error code I can give none, sorry.
Please help me.
Thanks in advance
- Misan
I am really new to javascript so dont blame me please.
I tried to perform a Spoiler, which went actually pretty good:
Code:
<script type="text/javascript">
function spoil(id){
if (document.getElementById) {
var divid = document.getElementById(id);
divid.style.display = (divid.style.display=='block'?'none':'block');
}
}
</script>
<a onmouseover="document.0.src='chars/guy_hover.png'" onmouseout="document.0.src='chars/guy.png'" >
<img style="cursor:pointer;" onclick="spoil('id0')" src="chars/guy.png" name="0">
</a>
However, I tried to add extra functionality: close all other spoilers when opening one.
I tried with a while which should close all spoilers, before opening a new one.
I changed the script to this, using a fixed value for the while because I have no idea how to count document.getele mentbyid elements :S
Code:
<script type="text/javascript">
function spoil(id){
if (document.getElementById) {
var divid = document.getElementById(id);
var i=0;
while (i<=300)
{
i.style.display = (i.style.display=='none');
i++;
}
divid.style.display = (divid.style.display=='block'?'none':'block');
}
}
</script>
Since javascript offers no error code I can give none, sorry.
Please help me.
Thanks in advance
- Misan
Comment