Home > ASP Development > Help - how do I make random images not random? Erm...

Help - how do I make random images not random? Erm...



Hello



I can't quite work out how to do this. Below is some really basic code to randomize images on one of my asp pages.



However, what I want to do is include a request.querystring("ID"), so that IF an ID is defined, eg ID=3, , it will display the relevant (not random) information. I've tried this every way I can think and get type mismatches, etc etc. It's probably really simple but I can't see it. Any help appreciated!



Cheers

KP



<%

limit=3

redim link(limit)

redim image (limit)



link(1)="xxx"

image(1)="image1.jpg"



link(2)="xxx"

image(2)="image2.jpg"



link(3)="xxx"

image(3)="image3.jpg"



randomize

random=int(rnd*limit)+1



%>

<center>

<a href="<%= link(random) %>">

<img src="<%= image(random) %>" border="0"></a>

    
Guest


Well, I can't help you with the ASP portion, but I can help you with a few things.



1. From what little bit I can see, you're XHTML isn't valid. <center> is a deprecated element. Also, <img> tags need to end with a forward space, followed by a forward slash and need to include an "alt" attribute (alternate text) in case the page doesn't load.. <img src="pic.gif" alt="pic.gif" />



2. You'd get a better response for this in the proper forum (ASP Development). This forum is for people to put working code samples in for other people's benefit. Message a moderator and see if they'll move it for you.



3. Please don't forget to wrap your codes in [ code][ /code] tags.

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by kevpick
Hello



I can't quite work out how to do this. Below is some really basic code to randomize images on one of my asp pages.



However, what I want to do is include a request.querystring("ID"), so that IF an ID is defined, eg ID=3, , it will display the relevant (not random) information. I've tried this every way I can think and get type mismatches, etc etc. It's probably really simple but I can't see it. Any help appreciated!



Cheers

KP



<%

limit=3

redim link(limit)

redim image (limit)



link(1)="xxx"

image(1)="image1.jpg"



link(2)="xxx"

image(2)="image2.jpg"



link(3)="xxx"

image(3)="image3.jpg"



randomize

random=int(rnd*limit)+1



%>

<center>

<a href="<%= link(random) %>">

<img src="<%= image(random) %>" border="0"></a>






Do you mean something like this?




Code:



<%
limit=3
f = request.querystring("f")
if f = "" then
f = 0
else
f = cInt(f)
end if

if f > cInt(limit) then
response.write "Error: Image does not exit"
response.end
end if

if f = 0 then
redim link(limit)
redim image (limit)

link(1)="xxx"
image(1)="image1.jpg"

link(2)="xxx"
image(2)="image2.jpg"

link(3)="xxx"
image(3)="image3.jpg"

randomize
random=int(rnd*limit)+1

else
random = f
end if
%>



Was this answer helpful ? Yes No   
Guest


--moved to the ASP forum.

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved