[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 03-04-2007, 05:12 AM   #1 (permalink)
NamePros Regular
 
Raz0rBlade_uk's Avatar
 
Join Date: Apr 2005
Location: United Kingdom
Posts: 630
76.50 NP$ (Donate)

Raz0rBlade_uk is on a distinguished road


Arrow $5 to paypal for help

Hi there.

Basically I am developing a site and I need a little help with some fairly basic code.

The idea is that I have an Iframe on the page which displays an html page that is based in a directory on the ftp. On the main page I would like to have a link which once clicked cycles through the pages which are based in the folder with a number of .htm files.

For example, you load up the site and the html file titled 10.html is displayed in the Iframe. You click the link (this link is not in the Iframe) and it loads up the next page in descending order, 9.html. You click again and it then loads up 8.html into the Iframe. I would like it to cycle through the files and then loop back to the start again.

Does anyone have any idea of how to do this? Is it actually possible?
Raz0rBlade_uk is offline  
Old 03-04-2007, 01:43 PM   #2 (permalink)
NamePros Member
 
Join Date: Feb 2006
Location: Online
Posts: 111
100.80 NP$ (Donate)

Barts has a spectacular aura aboutBarts has a spectacular aura about


Here ya go bro:

Code:
<html>
<head>
<script type='text/javascript'>
	var maxNum = 10;

	function loadNextLink(currentNum) {
		if (currentNum==0) {
			currentNum=maxNum;
		}
		document.getElementById('myIframe').src = "document" + currentNum + ".html";
		document.getElementById('myLinkToNextPage').href="javascript:loadNextLink(" + eval(currentNum - 1) +");";
	}
</script>
</head>
<body onload="loadNextLink(maxNum);">
<a href="javascript:void(0);" id="myLinkToNextPage">Click to load next page</a>
<iframe id="myIframe" width="400" height="200"/>
</body>
</html>
Just change the global var "maxNum" to whatever the maximum number of pages you have. Once it reaches 0 it will start over (0 will not be shown). This example documents should be named "document??.html" where ?? can be any number between 1 and "maxNum".

Good luck!
__________________
A soul?... I've got not use for such frivolities.
Barts is offline  
Old 03-04-2007, 02:50 PM   #3 (permalink)
NamePros Regular
 
Raz0rBlade_uk's Avatar
 
Join Date: Apr 2005
Location: United Kingdom
Posts: 630
76.50 NP$ (Donate)

Raz0rBlade_uk is on a distinguished road


Quote:
Originally Posted by BartMSX
Here ya go bro:

Code:
<html>
<head>
<script type='text/javascript'>
	var maxNum = 10;

	function loadNextLink(currentNum) {
		if (currentNum==0) {
			currentNum=maxNum;
		}
		document.getElementById('myIframe').src = "document" + currentNum + ".html";
		document.getElementById('myLinkToNextPage').href="javascript:loadNextLink(" + eval(currentNum - 1) +");";
	}
</script>
</head>
<body onload="loadNextLink(maxNum);">
<a href="javascript:void(0);" id="myLinkToNextPage">Click to load next page</a>
<iframe id="myIframe" width="400" height="200"/>
</body>
</html>
Just change the global var "maxNum" to whatever the maximum number of pages you have. Once it reaches 0 it will start over (0 will not be shown). This example documents should be named "document??.html" where ?? can be any number between 1 and "maxNum".

Good luck!

Thanks a lot. I will try it out. If all is well then send me a PM with your paypal address
Raz0rBlade_uk is offline  
Old 03-04-2007, 02:55 PM   #4 (permalink)
NamePros Member
 
Join Date: Feb 2006
Location: Online
Posts: 111
100.80 NP$ (Donate)

Barts has a spectacular aura aboutBarts has a spectacular aura about


It's okay. It was fun to solve your problem. Just give me some rep
__________________
A soul?... I've got not use for such frivolities.
Barts is offline  
Old 03-04-2007, 03:13 PM   #5 (permalink)
NamePros Regular
 
Raz0rBlade_uk's Avatar
 
Join Date: Apr 2005
Location: United Kingdom
Posts: 630
76.50 NP$ (Donate)

Raz0rBlade_uk is on a distinguished road


Quote:
Originally Posted by BartMSX
It's okay. It was fun to solve your problem. Just give me some rep
Oh Thanks man! How kind of you Rep++
Raz0rBlade_uk is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 06:52 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85