[thelist] JS add remove list items
fstorr
fffrancis at fstorr.demon.co.uk
Sat Nov 15 11:11:04 CST 2003
Hi all
I'm trying to replicate a very basic powerpoint type functionality in
JavaScript. The idea is to have subject headings as bullet points that
will appear when a "next" button is pressed. The page will start with no
bullets showing. When a "previous" button is pressed, the last bullet
item is removed.
My JavaScript isn't by any means great, and I've got this far, but can't
work out the rest. At the moment it just takes off/adds back the top
one. I've also noticed an annoying bug in Moz1.5 where the bullet point
isn;t replaced when the fist bullet point is put back in. Any help would
be appreciated:
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
</ul>
<p onclick="return bullet('add');">change +</p>
<p onclick="return bullet('remove');">change -</p>
function bullet(action)
{
var counter = document.getElementsByTagName("li");
for (i=0; i < counter.length; i++)
{
if (action == "add")
{
counter[i].style.display="block";
alert(counter[i].value);
return;
}
else
{
counter[i].style.display="none";
alert(counter[i].value);
return;
}
}
}
More information about the thelist
mailing list