/    Sign up×
Community /Pin to ProfileBookmark

Automating Next and Previous Button

I need help!

I have created a very basic (still learning!)CBL template using DreamWeaver. Everything is going well except for the navigation bar. I am wanting to create a next and previous button, where they can literally go back one page and forward one page etc.

So I come up with the following code:

[b][COLOR=darkblue]
<SCRIPT LANGUAGE=”JavaScript”>
<!–
function go(prf) {
var text = self.location.href;
var pos = text.indexOf (prf);
var poslng = prf.length;
var num = text.substring(pos+poslng,pos+poslng+3) – 0 + dir;
num = (num < 10) ? “00” + num : ( (num < 100) ? “0” + num : num);
window.location.href = text.substring(0,pos+poslng) +
num +
text.substring(pos+poslng+3,text.length);
}
//–>
</SCRIPT>
[/B]
[/COLOR]

From what I can tell – this will search dir with a number. eg fire001.htm, fire002.htm, fire003.htm and lets it advance by following the numbers up to 999.

Well.. it won’t work.. Every time I view it in browser – nothing happens when I click on link. ? Why?

Could someone please help me??

Thanks!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@96turnerriOct 21.2004 — probably this

window.location.href = text.substring(0,pos+poslng) +

num +

text.substring(pos+poslng+3,text.length);

make

window.location = text.substring(0,pos+poslng) +

num +

text.substring(pos+poslng+3,text.length);
Copy linkTweet thisAlerts:
@dreamxgirlauthorOct 21.2004 — Still won't work.. ?

I racked my brain.. and just can't get it to work..

I have 3 files I am testing:

fire001.htm (this is the main page - index)

fire002.htm - content

fire003.htm - content

I know I nearly have it.. just something missing
Copy linkTweet thisAlerts:
@sciguyryanOct 21.2004 — The problem seems to be that its a numeric value and not a string you'll need to do something like:

<i>
</i>var Loc = new String(text.substring(0, pos + poslng) +
num + text.substring(pos + poslng + 3, text.length));
window.location.href = Loc



Making it a string has solved problem in the past for me, it may work in this case.

RyanJ
Copy linkTweet thisAlerts:
@dreamxgirlauthorOct 22.2004 — Still nothing...

Here is what my script looks like now:

<SCRIPT LANGUAGE="JavaScript">

<!--

function go(prf) {

var text = self.location.href;

var pos = text.indexOf (prf);

var poslng = prf.length;

var num = text.substring(pos+poslng,pos+poslng+3) - 0 + dir;

var Loc = new String(text.substring(0, pos + poslng) +

num + text.substring(pos + poslng + 3, text.length));

window.location.href = Loc

}

//-->

</SCRIPT>

I think I will just give them a book to read! :rolleyes:
×

Success!

Help @dreamxgirl spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...