Random ASP Pages?
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 posted this at 16:59 — 2nd October 2000.
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
KLWong posted this at 14:42 — 4th October 2000.
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 .
Kristen, who has a parrot named "Simon"!
Kristen
http://www.RewardsLookup.com and
http://www.cancerdrugfeedback.net still under early development
Personal page:http://www.isd.net/kwong/kristen.html
Mark Hensler posted this at 06:55 — 12th October 2000.
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 posted this at 15:30 — 17th October 2000.
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.