473,765 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forward-Back menu bar in frames - numbered set of pages

I have a script that will navigate back and foreward using a form. The
files it navigates are named: bg1.html, bg2.html, bg3.html, etc.

This is happening in a frameset, where my BACK and FORWARD buttons are
in one frame, and the content pages are in another (main).

I can get read the current page location in the frame "main", but it
is not working (getpagenumber)- it should give the current page
number, and use that number to tell the rest of the script where Back
and Foreward is. The current page is "bg1.html"

My script is below, followed by the form that will use it. Any help or
advice would be appreciated:

<script language="JavaS cript">
<!--
function getpagenumber() {
var otherpage = parent.main.loc ation.href;
var pagenumber =
otherpage.subst ring(otherpage. length-3,otherpage.len gth);
return pagenumber - 0;
}

function goForward() {
var page = getpagenumber() ;
if (page < 100)
parent.main.loc ation.href = 'bg' + pad(page + 1,3) + '.html';
}
function goBackward() {
var page = getpagenumber() ;
if (page > 1)
parent.main.loc ation.href = 'bg' + pad(page - 1,3) + '.html';
}
function pad(number,leng th) {
var str = '' + number;
while (str.length < length)
str = '0' + str;
return str;
}
//--></script>


<form>
<input type="button" value="Back" onClick="goBack ward()">
<input type="button" value="Forward" onClick="goForw ard()">
</form>
Jul 23 '05 #1
2 1431
Lee
Chris said:

I have a script that will navigate back and foreward using a form. The
files it navigates are named: bg1.html, bg2.html, bg3.html, etc. <script language="JavaS cript">
<!--
function getpagenumber() {
var otherpage = parent.main.loc ation.href;
var pagenumber =
otherpage.subs tring(otherpage .length-3,otherpage.len gth);
alert(pagenumbe r);
return pagenumber - 0;
}


Ignoring the problems involved with frames and the fact that
your <script> tag and comment lines are out of date, the first
step in debugging this script should be to add an alert() as
shown above to see what value you're getting for pagenumber.
That should tell you what you need to fix.

Jul 23 '05 #2
Chris wrote:
<snip>
... named: bg1.html, bg2.html, bg3.html, etc. <snip> <script language="JavaS cript">
<!--
The usual comments about the deprecated language attribute and the
outdated HTML comment script hiding practice applies to the above.
function getpagenumber() {
var otherpage = parent.main.loc ation.href;
var pagenumber =
otherpage.subst ring(otherpage. length-3,otherpage.len gth);
This substringing operation should return the last 3 characters in the
page's URL. Assuming no query string or fragment identifier, that should
be "tml" for a file with a ".html" suffix.
return pagenumber - 0;
Subtracting zero form the string "tml" will force a type conversion of
the string to a number prior to the subtraction. "tml" is no a number so
the result will be NaN, and all subsequent mathematical operations
acting on NaN will themselves return NaN.
}

function goForward() {
var page = getpagenumber() ;
if (page < 100)
NaN is never less than 100.
parent.main.loc ation.href = 'bg' + pad(page + 1,3) + '.html';
}
function goBackward() {
var page = getpagenumber() ;
if (page > 1)

<snip>

And NaN is never greater than 1.

Richard.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5467
by: mjm | last post by:
Folks, Please help me with the following problems: ******************************************** 1. I have a class template template<class Base> class Matrix : public Base { /* .... */ }
1
1913
by: qazmlp | last post by:
Is it a good style to re-forward declare the types, which were already forward declared in base header file, in derived class header file? // base.h class addrClass; class base { public: virtual void setAddress(addrClass* node);
6
5216
by: Steven T. Hatton | last post by:
Should I be able to forward declare something from a namespace different from the current one? For example the following code compiles: //testdriver.hpp #ifndef TESTDRIVER_HPP #define TESTDRIVER_HPP #include <ostream> namespace ns_testdriver{ using std::ostream;
5
10371
by: Simon Elliott | last post by:
For some time I've been using typedefs for STL containers for reasons outlined in: http://www.gotw.ca/gotw/046.htm However a major downside to this is that you can't forward declare a typedef of a STL container: #include <vector> struct foo
5
6191
by: Todd Huish | last post by:
I have noticed something disturbing when retrieving datasets over a relatively slow line (multiple T1). I am looking at about 25 seconds to retrieve 500 rows via a php-odbc link. This same select from the cli is for all intents practicaly instantaneous. After much research I discovered that PHP by default uses a dynamic cursor type which can be quite a bit slower than a forward only cursor. BTW I have been searching forward only/read...
23
3858
by: mark.moore | last post by:
I know this has been asked before, but I just can't find the answer in the sea of hits... How do you forward declare a class that is *not* paramaterized, but is based on a template class? Here's what I thought should work, but apparently doesn't: class Foo; void f1(Foo* p)
7
5999
by: Noah Roberts | last post by:
I have something like the following: template<ENUM X, int I = 0> class Generic { .... }; typedef Generic<Val1> v1_type; typedef Generic<Val2> v2_type;
6
8619
by: Hunk | last post by:
Hi I have a question on usage of forward declarations of templates. While searching through this group , people suggested using forward declarations and typedefs for templates as // in myfile.h template<typename T,typename R> class some_class;
4
20497
by: aj | last post by:
DB2 LUW v8.2 FP 14 RHAS 2.1 I have a DB2 online DB backup that was done w/ the INCLUDE LOGS option. I am interested in restoring that backup, and rolling forward ONLY the logs contained in the backup and no more, then bringing the DB online. I do not want to use a userexit to try and retrieve additional logs - I only want to roll forward the logs in the backup. (In case you haven't guessed, I am restoring a test version of my
11
8332
by: Jef Driesen | last post by:
I have the following problem in a C project (but that also needs to compile with a C++ compiler). I'm using a virtual function table, that looks like this in the header file: typedef struct device_t { const device_backend_t *backend; ... } device_t; typedef struct device_backend_t {
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.