Random ASP Pages?

They have: 12 posts

Joined: Mar 2000

Hi,

I have ten different ASP pages, that I would like to display randomly.

I did try to modify this code that I did find online but, there is an error, it just display this on my page:

'random' 10.asp'

What should I change in my code to make it work?

I hope to receive news from you soon.

Simon Baillargeon

<?php
randomize
dim textRandomNmumber
textRandomNmuber
= rnd*10
textRandomNmuber
= int(textRandomNmuber)+1
?>

<?php
response
.write "random"&textRandomNmuber&".asp"
?>

Simon Baillargeon

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi Simon,

I'm not an ASPer, but... when I ran your code (using document.write() instead of response.write), I got "randomX.asp" where X was the random number. If you are attempting to load the random page, I would presume you need something to tell it to load. Something like:
window.location="random"&textRandomNmuber&".asp"

Vinny

Where the world once stood
the blades of grass cut me still

They have: 135 posts

Joined: Apr 2000

I hesitated to reply because I don't have my ASP books here at work, so I can't give a detailed answer. But I think you need to put textRandomNmuber through a function to change it from a number into a string. Something like this:

<?php
Filename
= "random" & Str(textRandomNmuber) & ".asp"
?>

Str() may be the wrong function name, but there's something (in ASP or VBasic) along these lines for this kind of type conversion. You can either look it up, or maybe some kind forum member will post it here Smiling.

Kristen, who has a parrot named "Simon"!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

CStr() may be the function your refering to, Karin.

But I don't see why you need to convert number to a string... Your appending it to something. Why should ASP/VB care if your appending a str or int?

Mark Hensler
If there is no answer on Google, then there is no question.

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Simon,

Your code should work fine. Remember if you want the random ASP page to load you'll have to use:

<?php
Response
.Redirect "random" & textRandomNmuber & ".asp"
?>

Regards,
Peter J. Boettcher

PJ | Are we there yet?
pjboettcher.com

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.