QUOTE(pandy @ Feb 13 2009, 01:17 AM)

QUOTE
Anyway, this looks like a convoluted way of getting the value of the function argument "divid":
QUOTE
CODE
var ThisAnswer = document.getElementById(divid).id;
How else would you get it? document.getElementById(divid) returns the object, not the id name.
The function argument "divid" already has the value:
CODE
alert(divid);
QUOTE
QUOTE
Also, this is lacking the "s":
CODE
var LastAnswer = ThisAnswer.substring(1) -1;
...and if you prepend the "s" I recall you must also do the multiplication with 1 to make javascript realize the other part is a number.
But that's what you want, the id with the s prefix shaved off.
I was assuming that the "s" was included in the function call parameter:
CODE
<a href="java script:doSection('s2')">Ghosts</a>
then you must of course remove it before the subtraction. After the subtraction you can prepend the "s" again. Finally, since I did all of this on one line I used the multiplication to tell the JS engine that part was a number (and not a string), though it seems just a parenthese (like you did it) is enough:
CODE
var previousID = 's' + (divid.substring(1) - 1);
But of course you might simply use plain numbers in the function calls instead:
CODE
<a href="java script:doSection(2)">Ghosts</a>
(no single quotes are necessary with numbers) and prepend the "s" in the script after doing the subtraction. Afraid I didn't look at the page before posting my first reply.
QUOTE
QUOTE
QUOTE
While this is really enough.
CODE
var LastAnswer = divid.substring(1) -1;
alert(LastAnswer);
No, (besides the "s" problem) the variable LastAnswer is meant to hold the
element with an ID (so you can show/hide that element), not the value of the ID.
The substraction still must be done without the s. Easy enough to put back.
That's what I did in my first reply: remove the first character (the "s"), subtract 1, and prepend an "s".