[thelist] javascript "won't" subtract

Emma Jane Hogbin emmajane at xtrinsic.com
Sat Mar 8 12:28:01 CST 2003


On Sat, Mar 08, 2003 at 01:13:47PM -0500, Emma Jane Hogbin wrote:
> Tom suggested:
> > This is untested but should work. I'm not sure why you are using
> > visibility, I didn't take much of a look into the page so I left it
> > there. Also, not sure where you are hiding the previous one, but you
> > could handle that here too.
>
> At this point I'm not hiding the previous one. Next seems to work ok
> without hiding the previous one (sort of -- it still peaks through). I'll
> add that bit now.

Weird!!! This seems to have fixed it. (At least it's a heck of a lot
closer to what I want.) here's the "working" script with comments.

function showImg(choice) {

// Get the current image from the form.
        var img = parseInt(document.forms[0].nextVal.value);

// Create a new variable to hold the new slide
        var slide;
// Check to see which button is called and then
// calculate the new slide.
        if (img <= 0) { slide = 1; }
        else if (choice == "start") { slide = 1; }
        else if (choice == "next") { slide = img +1; }
        else if (choice == "prev") { slide = img - 1; }

// Get the style property for the correct slide/div.
        var photo = document.getElementById(slide).style;

// Undo the "invisible" layer by changing the display
// and the visibility. the visibility is actually optional
// because the default CSS affects display, not visibility.
        photo.display = "block";
        photo.visibility = "visible";
        document.forms[0].nextVal.value = slide;

// These two lines are new. The hide the previously selected
// slide. This is REQUIRED to get the 'math' part to work
// above.
        var current = document.getElementById(img).style;
        current.display = "none";
}


--
Emma Jane Hogbin
[[ 416 417 2868 ][ www.xtrinsic.com ]]



More information about the thelist mailing list