CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Random Image Display

Print topic Send  topic

Author Message
wayner


Posts: 37
Posted: 10/26/2004, 7:11 AM

Gentlemen,

I am trying to implement random images on the main page of the Portal example (ASP version) but this code will not display them. This code is from ASP101, I have tried several different modifications.

This example selects a random image from a set amount . We have a total of 6 images and in this example they are store in the images directory and have the names a1.gif to a6.gif.
Here is the code.

(Would this be coded in the asp page or html event?)
'declare our variables
Dim pics , totalPics , picFileName
'6 images in this example
totalPics = 6
'get a random picture
Randomize
pics = Int((totalPics*Rnd)+1)
'create filename
picFileName = "images/" & "a" & pics & ".gif"

Now to display the random image on the page we place the following where we require the image.

(Would this be coded in the html page?)
<img src="<%= picFileName%>">

Any help would be appreciated.

Thanks,

Wayner
_________________
Have it your way, sort of!
1. You can have it fast.
2. You can have it cheap.
3. You can have it accurate.
Pick 2 out of the 3!
View profile  Send private message
mrachow


Posts: 509
Posted: 10/26/2004, 9:57 AM

I would add an image using Toolbox | Forms.
In the BeforeShow event you can set the value of the image control to your image path.

Hope this helps.

Michael
_________________
Best regards,
Michael
View profile  Send private message
wayne
Posted: 10/27/2004, 1:18 PM

Thanks for the help but it did not work.

I added an image (image1) and changed the related code but it still does not show the image. Do I need to add some formatting to the "<img src=..." statement for it to recognize the filename in the variable?

Thanks again,

Wayner
mrachow


Posts: 509
Posted: 10/28/2004, 1:01 AM

I'm not quite sure what you have done.
You should not change code.
In event BeforeShow / Custom code you should add something like
$<theForm>->Image1->SetValue("<pathToImage>");
(If the image is placed on a form the name of the form shpould be given by a global above the slot for inserting code.
The "value" of an images control is just the value of its src tag.

Hope this helps!?
Michael
_________________
Best regards,
Michael
View profile  Send private message
mrachow


Posts: 509
Posted: 10/28/2004, 1:17 AM

Sorry, I thought I was talking about PHP.
The way how to do it is of course the same.
But here is no global and syntax uses . instead of ->
(form.Image1.Value = "path")

Michael
_________________
Best regards,
Michael
View profile  Send private message
wayner


Posts: 37
Posted: 10/28/2004, 9:57 AM

Thanks Michael

That did work for me! In fact I have incorporated the image urls in a database and it randomly selects the image on open or refresh.

Wayne
_________________
Have it your way, sort of!
1. You can have it fast.
2. You can have it cheap.
3. You can have it accurate.
Pick 2 out of the 3!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.