Random Images Usin Array

I'm trying to have my program randomly select one of five images. I think my syntax is correct (that is it isn't giving my any error messages and the page loads with the image being replaced by a broken link 'X' box), but I don't know how to display the image to the screen.

Should the response.redirect part automatically display it to the screen or should I have it in some tag like <td><img scr ="lrandom"></td> within my table?

<% dim array(5)
randomize

array(1)="img1.gif"
array(2)="img2.gif"
array(3)="img3.gif"
array(4)="img4.gif"
array(5)="img5.gif"

upperbound=ubound(array)
lowerbound=0
lrandom = Int((upperbound - lowerbound + 1) * rnd + lowerbound)
response.redirect "images/" & (Array(lrandom))
%>

View Replies


ADVERTISEMENT

How Do I Make Random Images Not Random?

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.

<%
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>

View Replies View Related

Random Images

is there sombody who can helpme witht he following, i am ''pretty new'' to
php and am looking for a script to show images randomly at a 10/ 15 seconds
interval. is there anybody who can help me with this or does know where to
find a good template script for this?

View Replies View Related

Selecting Random Images

Is it possible to select random images from a directory without creating a "library"

As in I want to have a directory with 25 or so images and want to randomly select an image without having to change the txt document when I add new images.

View Replies View Related

Random Display Of Images

I am trying to retrieve images from the database and display them in a random order. The order of the images is supposed to change each time page is refreshed. Below is my code, I am using an array to store the images but the images are not displayed for some reason. Code:

View Replies View Related

Images From Random Rotation

I come from a PHP background. I'm modifying a client site that uses some critical ASP code in the backend, so for simple frontend stuff I need to use it too!

I need to make sure that certain images from a random rotation only appear on certain sections of the site licensing issues. Is there any way to easily grab the name of the file that's currently loaded? I want to run some form of regex on it to check for certain words.

View Replies View Related

Random Images Divide Into Three Groups?

I have a bit of a problem.

Basically I have a homepage, when the page loads up it will display images.

However, the images are dived into three groups, as seen below.

Group1 - Image1, Image2, Image3

Group2 - Image4, Image5, Image6

Group3 - Image7, Image8, Image9

What I want is that every time when someone enters the front page, it should pick a group and display that particular set of images on the homepage.

View Replies View Related

Random Display Of Images Dynamicly From Database

I am trying to retrieve images from the database and display them in a random order. The order of the images is supposed to change each time page is refreshed.

Below is my code, I am using an array to store the images but the images are not displayed for some reason. Any help would be appreciated.

<% Dim rstResult
Dim strSQL
Dim img(100)
imgID = 0
set rstResult = Server.CreateObject("ADODB.Recordset")
strSQL = "sp_sel_TilesByType 'O'"
rstResult.Open strSQL, strConnect

set rResult = Server.CreateObject("ADODB.Recordset")
sSQL = "sp_sel_TilesByType 'O'"
rResult.Open sSQL, strConnect


if not rResult.EOF then

do while not rResult.EOF
response.write("hi")

imgID = imgID + 1
img(imgID) = "images/tiles/" & rResult("TileImage")
response.write(img(imgID))
rResult.movenext

loop
end if

if not rstResult.EOF then
intVendorID = 0
do while not rstResult.EOF


if intVendorID <> rstResult("VendorID") then
rndNumber = RandomNumber(imgID)
Response.Write "<p>"
Response.Write "<a href=javascript:popWin('tileview.asp?" & rstResult("TileID") & "','',1,1,1,1,700,600);>"
'Response.Write "<img src=images/tiles/" & rstResult("TileImage") & " border=0>"
response.write(rndnumber)
Response.write "<img src=img(rndNumber)>"
Response.Write "</a>"
Response.Write "</p>"
end if
intVendorID = rstResult("VendorID")
rstResult.MoveNext
loop
end if
set rstResult = nothing%>

View Replies View Related

Displaying Images At Random From SQL Query String

I have a database of images with captions that I need to display at random on an ASP page. Once I have pulled out my recordset, what's the best way to select on item at random from the recordset to display? Also, at first I might have only 5 items in my recordset, how can I avoid the same item repeating 3 times in a row if the person clicks refresh?

View Replies View Related

DB Random Records From Array

I have read 10000 opinions on returning random records and I am more
confused now that before I started. I have a small access db that will
contain 20 or so rows with 3 or 4 columns. I like to return a set of 6
distinct rows and display the columns in html. I have seen response.write
and loops but can't I throw the 6 random rows in a array and pull the data
as I need it in the page? Examples?

View Replies View Related

Writing Array Of Random Numbers To A Database

I am trying to write an array of random numbers to a database. The array part is working fine, but when I go to update the dataabse, it inserts the last value of the array into all the fields in the database .....

Dim MyValue,sqlRandom
Dim arrayRandom(8)
for i = 1 to 8
Randomize
MyValue = Int((100 * Rnd) + 1)
arrayRandom(i) = MyValue
response.write "<p> Array Value:" & arrayRandom(i)

sqlRandom = "UPDATE CarParkDetails SET FreeSpaces = '" & arrayRandom(i) & "'"
Conn.execute(sqlRandom)

next

I can't see whats wrong!

View Replies View Related

Making It Random (getting Random Numbers)

I just wanted to know whats the best way to generate 50 or say X amount of number at random without having to repeat any of the previous number...

so far I've the following:

[VBS]<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
function RandomNumber()
dim theRandom

Randomize
'RandomNumber = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

theRandom= Int((99 - (0) + 1) * Rnd + (0))

if (theRandom<10) then theRandom = "0" & theRandom

RandomNumber = theRandom
end function
%>[/VBS]

and then I've this in the body of HTML doc: Code:

View Replies View Related

Random Token Generator - Not Really Random

We have the need to have a random token (a 16 char alphanumeric field) to be used as the key for one of our SQL tables. I have created a random token generator, however after only 3 months in production, it appears that we had an instance where a token that already existed in the tables was created. There are 3810 records currently in the database so it isn't like there are billions of records there.

I contacted an old college buddy of mine who is a mathematician, and he claims, assuming that random really does mean random, that the chances of getting a duplicate token are 1 in 79.5 septillion (79,500,000,000,000,000,000,000,000).

So my conclusion is that this was either a complete freak of nature occurance, or my random generator isn't really all that random. Here is the code behind how I am generating this: Code:

View Replies View Related

Random Number Not Random

I am trying to generate a random number. I am using randomize and then rnd to return a decimal number between 100 and 120. This will give me a longitude. I am doing something similar to generate a latitude.

I created this on a page which refreshs every minute. I put these points into a map and they are showing up in groups of straight lines. Since rnd is time based will refreshing every 60 seconds return similar numbers?

View Replies View Related

How To Resize All Images Sizes And Coordinates Of The Images On Resize Browser

My page have background image,on that image have more images and text. My problem is whenever resize browser that images are not resized and also not moved correct place .(i.e look not like before alignment).I want to do everything in dyanamic....

View Replies View Related

Rebuilding Of An Array From An Existing Array

I dump the entire recordset into an array:

If not rs.EOF Then
aEmp = rs.GetRows()

Contents of the array are in this order:

EmpID,EmpName,Indent,Sub_ID,Lft,Rgt,MgrID, LastName

This query sort on the basis of Lft and Rgt columns.

The name of the array is: aEmp.

My question here is how can I get only the LastName from the aEmp array into another array so that I can sort the names alphabetically and then display the employees in the alphabetical order.

Or is there is another way I could this by using the same array while keeping the lft and rgt sort of the query? If I sort based at the SQL query level, I can see the names sorted by the lft, rgt and lastname, but since the lastname is at the end of the sort list - it does not appear alphabetically.

View Replies View Related

Array Integers Vs Array Variables

In working with arrays, I have found that I am unable to dimension and array
with a variable that has an integer value but I can redimension one this
way. I haven't see any information that tells me if this is a requirement,
although it appears to be because I get an error if I try it.

Ex.

Dim b
b = 10
Dim a(b) ' this errors out but
Dim a() ' this
Redim a(b) ' works

Code:

View Replies View Related

Create A New Array From An Array

I want to create a new array called arrNames2 and copy contents of arrNames to arrNames2.

I then want to loop through my db and add more names (while going through the loop) to arrNames2. What is the best way to do this? Do I have to keep redim the array wehn I add more names?

View Replies View Related

Random Row

I want to display data of a Random Member on my page.. and I did a search in these forums and I tried to do this:

[CODE] SELECT tblMiembros.*, tblDatosPersonales.*
FROM tblMiembros, tblDatosPersonales
ORDER BY rnd(isnull(tblMiembros.ID_APLICANTE) * 0 + 1)"[/CODE]

This doesnt throw any errors. but it always displays the same row... (first in database)

am I doing something wrong? am I missing something?

View Replies View Related

Regarding Random

I have a client asking me about random images on his site, basically I am using the following code:-

<%
 RANDOMIZE
 Response.write("<IMG SRC='../gfx/bg-img0" & INT((3)*RND()) & ".jpg'>")
 %> 

Agreed its not the best code, but he is finding that the same image could be repeated like three times in a run.

I have an include file which displays the image, and the random script is placed inside that include. So when he is going from page to page this is where the issue lies.

Can anyone help me out here, is it even possible to have a different image load each time, and not have them repeating.

View Replies View Related

Random Value

I am using random number to be used as a unique identifir. Since random numbers are in decimals I am using going to convert it into an integer and since I need to append this Id into my URL, I am converting it into a string. SO my formula looks like this.

CStr(Int((Highest-Lowest+1)*Rnd+Lowest))

S0 now every time a new record is generated would this formula generate a unique number for unique identification in the table. I can't see how it can do it. Say A user is assigned a random number; then another user subscribes so how would the server determines that the random value assigned to next user is not already assigned to any other user.

In case if this can't work (a unique ID for every user) then I'll stick to this very same formula and after the random number is generated, I'll check this number with the table in the database and see whether it's been assigned already. If yes, I'll request another random value, if not then I'll go with it. Is this the right strategy?

View Replies View Related

Random Image

I have done random image display with the help suggestion from this discussion form. now I want to provide link on each image. i.e. all the images display randomly, should have different link. is it possible? if yes, how?

View Replies View Related

Random Image

example:

When u see some sites ,
the advetisement images are changing ,

when ever the browser is refreshed...

.....

like tha i want to do that.....

View Replies View Related

Random Image

I have the below ASP function to display a random image from a folder.

<%
Function RandomImage(strPath)
Randomize()

If Right(strPath, 1) <> Chr(47) Then strPath = strPath & Chr(47)
strPhysical = Server.MapPath(strPath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:Inetpubwwwrootpag-siteimages
andoms")
Set objFiles = objFolder.Files

For Each objFile in objFiles
strFile = LCase(objFile.Name)
strFiles = strFiles & strFile & vbTab
Next

strImages = Split(strFiles, vbTab)
If UBound(strImages) > 1 Then
RandomImage = strPath & strImages(Int(Rnd(1)*UBound(strImages)))
End If
End Function
%>

and this places the image in the HTML

<img name="Intropic" src="<%=RandomImage("images/randoms/")%>" width="211" height="158" alt="" />

but sometimes the script places a ._ before the image file name in the outputted HTML?

View Replies View Related

Getting Random Errors

I'm afraid I have a technical problem here. Basically what happens is that I'm getting some random errors(like Type mismatch... etc) that shouldn't under normal circumstances occur. Then I connect to my server via remote desktop and Recycle the application pool on which my asp pages run. Errors then disappear

View Replies View Related

Random ASP File?

I have a file where i want to call a random asp file using the "include file" statement. I know it can be done with images, but can it be done with other asp files? and how?

View Replies View Related

3 Random Records From DB

I want to take 3 records from a database. The selection must first take any record marked as priority and then random records (so there could be 3 priority records and no more or 1 priority and 2 random etc)
My theory is to build a recordset filtered by records marked priority, and if there are less than 3, build a second recordset of all the other records.
Questions
1, how can I select random records form the second recordset, without selecting the same one twice?
2, OR, could I write a sql statement which would randomly select 3 records from my table
3, Or is they a way I could write a query (view) in Access which would do the whole lot for me (select the priority records and then random records up to 3)?

View Replies View Related

Random Code

I set up a random code for people registering with my site.....

letters="1234567890abcdefghijklmnopqrstuvwxyz"
for i=1 to 16
Randomize()
rNum=Int(Rnd()*36)+1
code=code&mid(letters,rNum,1)
next

but for some reason it sometimes saves code as an empty string. When I register a fake name, ie zzz, it seems to work fine, but for some of my members is saves as an empty string.

View Replies View Related

Random Number

trying to get a random number from 0000 to 9999, is there an easy way to do this? i'm using this for a unique filename and want it to be 4 digits from 0000 to 9999.

View Replies View Related

Random String

How do i produce a random string.anything from A-Z or a-z or 1-9 for the password.how do i do that

View Replies View Related

Shuffling / Random

i have a db where ± 15 users stores multiple second hand items with images. Now i wish to display on the openingpage a list of all users with 1 item + image. So far no problem.

But now i wish to change the order of the users every time the pages open.

How can i shuffle the recordset before i load the users in a array, or how
can i shuffle the array after populating with the users? Code:

View Replies View Related

Random # Generation

I'm trying to sort a list of 10 people into two groups--RANDOMLY. I've gotten as far as to generate a random number and assign a name to it. I just need to know how to generate 9 more numbers, making sure no numbers/names repeat. Code:

View Replies View Related

Random Record From DB

I have a DB with 10 items and an SQL statement:

"SELECT * FROM myTable WHERE Activate=true"

How do I make it so that every time the page refreshes it will display a random record?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved