Print Page | Close Window

Random includes

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5760
Printed Date: 31 March 2026 at 4:47am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Random includes
Posted By: JDYoung
Subject: Random includes
Date Posted: 15 September 2003 at 11:37am

Is it possible to have random includes?  If I have three different pages, is it possible to have it randomly select one of the three pages?

 

 

Thank you,



-------------
JD



Replies:
Posted By: michael
Date Posted: 15 September 2003 at 3:19pm
Theoretically yes, you can use includes in your randomize function though all pages get always included, no matter what. You can put the content in a db field and query it that way.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: JDYoung
Date Posted: 15 September 2003 at 3:29pm
I am not sure I really unstand.

-------------
JD


Posted By: Mart
Date Posted: 16 September 2003 at 9:56am

Dim randomstring

Randomize

randomstring = INT(rnd()*10)

Do While randomstring > 3

randomize

randomstring = INT(rnd*10)

Loop

randomstring = "page" & randomstring & ".asp"

server.execute randomstring



Posted By: JDYoung
Date Posted: 16 September 2003 at 4:04pm

Thank you.  I am still a but unsure how this code is put into a page and unsed.  I have my main page & would like to randonmly include 1 of the 3 files (a header ) into the main page.

So would I insert your code into the main page where I want one of the random <!--#include virtual="includes/header.asp" --> files to be place?

Thank you again!



-------------
JD


Posted By: michael
Date Posted: 17 September 2003 at 7:55am
Mart is using Server.Execute which has the advantage of using variables as a filename, that luxury you don't have with SSI includes. Just put his code to wherever you want the page to be executed.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net