Random Picture Display Script

Apr 17, 2006

I am working on a web page where a random picture is displayed at each visit to the site. One requirement of the page is that it also works for users who have javascripts disabled.

I put a default picture in the page that get's swapped using an onLoad function. That works great for the javascript disabled browser because it just shows that default picture. However, when the page loads for users who do have javascripts enabled, they will see the default picture quickly change into the new random picture. It looks glitchy.

I've been trying to think of another approach where it will be seemless for either kind of viewer. Any ideas? Code:

View 9 Replies


ADVERTISEMENT

Random Picture By Js To Be Posted To Php?

Jun 12, 2011

The background of this thread is about CAPTCHA:

HTML Code:
<script language=javascript>
id=Math.round(Math.random()*2)+1
document.write("<img src="+id+".jpg>")
</script>

above is the js code I use to generate a random id, which in effect displays id.jpg on the web page (assume we have id.jpg in the right folder).

When a user sees that page, he is going to choose what word describes the picture best. (purpose of CAPTCHA: verify the user is a human)

HTML Code:
<select name="selected[1]">
<option value="">Click to identify</option>
<option>Clock</option>
<option>Dog</option>
<option>Ship</option>
<option>Tree</option>
</select></td><td>

The selection is sent to backend php script using POST method.

Here is my problem: In the php script, I know, for example, the user chose Dog to describe the mysterious jpg generated by js code. But there's no way for me to know the id of the jpg file generated by js code. Hence, I will not be able to check whether the user chose a valid description of the jpg file.

How can I send information about the id of the jpg file to the php script?

View 1 Replies View Related

Using Random Picture Generator - In A Quiz ?

Mar 22, 2009

I'm trying to make a Quiz that generates random pictures each time the page is launched , with multiple options for the user to choose the right answer satsifying the picture and its meaning .

I've made the pseducode and i understand the algorithm ..but i don't know how to write the statements .

My algorithm is :

1-Random picture is shown each time the page is launched.

2- 6 Buttons are placed .

3-user choses the right matching answer.

4- window is popped up saying "correct"when its correct if not , an alert saying ;'Your answer is incorrect. Please try again"

So this is the code i've made , i know there's errors but just to show the Idea.

View 4 Replies View Related

Post Random Picture W/ Array And For Loop?

Mar 28, 2009

Ok heres my deal. I want a javascript that generates a random picture everytime it is refreshed i got this code which is here:

<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var theImages = new Array()

[code]....

View 16 Replies View Related

Display User Uploaded Picture?

Jun 16, 2009

I'm working on an application that is supposed to allow a user to upload a picture, which would be immediately displayed... how do I go about doing this?

View 1 Replies View Related

Display A Picture When It Is Clicked Within Various Color Mats And Frames

Apr 8, 2010

I need to display a picture when it is clicked within various color mats and frames.

View 1 Replies View Related

Display A Preview Picture When The Cursor Hovers Over A Link - SetTimeOut Object

Jun 4, 2011

i am trying to make a script that will display a preview picture when the cursor hovers over a link. i have the basic functionality down but noticed that I should probably have some kind of delay so the user is not ambushed when they move their cursor over the links. i figured i could just implement a setTimeOut() function but i can't seem to get to work. i am including the source of what i have so far.

[Code]..

View 1 Replies View Related

Calling Function \ Working On The First Img (picture) Want It To Be Called On The Second Picture?

Apr 28, 2009

The code is working 100%, but the only problem is with the function calling statement. It is working on the first img (picture) i want it to be called on the second picture.

<!DOCTYPE html PUBLIC "-w3cDTD xhtml 1.0 strict EN"
<html xmlns=http:www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = http:www.w3.org/1999/xhtml">

[code]....

View 1 Replies View Related

Broken Picture Link - Change A Picture In A Program?

Nov 23, 2010

I am trying to change a picture in a program but I keeps being a broken picture link.

[Code]...

View 1 Replies View Related

Picture Gallery - Title To Change According To The Picture Selected

Jan 23, 2011

I've been working on photo gallery that can be seen here: [URL] I would like the title to change according to the picture selected. This works when you click on the thumbnail images. However, it current does not work with the drop-down menu, "back" and "next" buttons, or the automatic slide-show.

[Code]...

View 4 Replies View Related

Stretch Picture In Background And Put Some Divs Over That Picture

Jul 19, 2010

i looking for a way to stretch picture in background and put some divs over that picture with links and text. what i find so far don't work in all browsers any one know something like this?

View 5 Replies View Related

Display A Random Image?

Jun 14, 2011

i have the simple code below to display a random image; how can i modify this line to place the random image at 225px wide by 141px high?

Code JavaScript:
document.getElementById("highlight_1").src = randomimage1;

View 1 Replies View Related

JQuery :: Product Display Script - MouseOver A Thumbnail Of A Product - A Larger Picture Appears Fading In

Oct 6, 2009

I came across this website

If you mouseOver a thumbnail of a product, a larger picture appears fading in and doing a quick slide at the same time. On mouseLeave, it does the reverse.

View 1 Replies View Related

JQuery :: Display A Random Div On Load?

Sep 12, 2010

Im just trying to display a random div on load.

I have adapted someone elses code to try and make it work for divs (was originally for changing background) the divs are both hidden on load

$(document).ready(function(){
var randomNum = Math.ceil(Math.random()*2);
var number = null; $.each([1,2], function(){

[Code]....

View 3 Replies View Related

Random Movie Display Script?

Oct 5, 2009

I have a Javascript which I'm using to display one of four Flash SWF files randomly. These need to be actually displayed twice, so I'm basically calling the script twice.This works great aside from one thing- occasionally the same movie appears in both scripts, for example the first instance picks movie 3 of 4 and th second instance does the same.What I need is to somehow make sure that if the first instance of the script picks movie x then the second script will pick any movie EXCEPT movie x.

This is the script as it stands:

<script language="JavaScript">
// Generate a Random Number
var randomnumber = Math.round(Math.random()*3);

[code].....

View 4 Replies View Related

Display X Random Values From Array?

May 7, 2011

I have an array containing 100 different values. How would I randomly pick 25 of them for display? For now I do: for (var i=0; i<markers.length && i<25; i++) {

html += markers[i].name + '<br />';
}

Which of course returns 25 values but always in the same order which is not what I want. PS. My array could also contain only 20 values, in which case I would like the function to display the 20 values randomly sorted.

View 2 Replies View Related

Display A Random Number Using InnerHTML?

Oct 15, 2011

I trying to display a random number using innerHTML

Here's my code:

HTML Code:
<html>
<head>
<script language="JavaScript">

[Code].....

View 1 Replies View Related

How To Display Random Text Automatically

Jun 9, 2011

how to display random text automatically with out refreshing webpage using java script...

View 9 Replies View Related

How To Display Random Message With No Repeats

Nov 15, 2009

I am trying to display a random number, but each time a button is pressed that calls the test function, i don't want to random number to be repeated. I know I have to declare 2 variables and a while loop, but i'm stuck as to what to put in the second variable and in the while loop.

var random = Math.floor(Q * Math.random());
var random2 = ??
function test () {
document.write(random);
while (random == random2) {
document.write(random);
}}

View 5 Replies View Related

ShowImg Function - Display Random Images

Jan 19, 2009

I have to access code in an external javascript page (random.js) which I have done. But then I have to create a second script element to create the function showlmg() and within that I require statements to declare a variable named imgNumber equal to the value returned by the randomInteger() (which is from the external sheet found in data files from the textbook therefore I know they are right). I am supposed to use 9 as the value of the size parameter in the randomInteger() function. The second statement should be command that writes the following text to the document: <img src='imgNumber.jog' alt= ' '/>.

So basically the coding I have done is:
<script type= "text/javascript" src= random.js"> </script>
<script type="text/javascript">
function showlmg() {
var imgNumber= randomInteger(9);// Return a random number from 0 to 9.
document.write("<img src='imgNumber.jpg' alt=''/>");
}
</script>

All in the head of the document and then
function randomInteger(size) {
return Math.floor((size+1)*Math.random());} from the external file.
and
<tr>
<td colspan="2" class="center">
<script type= "text/javascript">
showlmg();
showlmg();
showlmg();
showlmg();
showlmg();
</script>
</td>
</tr>

To post in a table on the page... I believe the issue is in the declaring a variable the is equal to the result of the function random integer which the text book or anywhere that I can find online fails to explain how to do.

View 5 Replies View Related

Display A Random Image Of Images I Select?

Dec 19, 2009

Does anyone have a script, that can display a random image of the images I select?:confused:I'm going to use it for a type of captcha. I think this would be easier in javascript, so yes I am in the right section.

View 7 Replies View Related

Click On Picture Fo Bigger Picture

Oct 17, 2006

I'd like to know please if there is a Javascript solution for enlarging pictures.

The outcome I am seeking is for the user to click on a thumbnail picture which then links to a bigger picture I dont want to use a HTML hyperlink.

View 4 Replies View Related

Display Random Text At Bottom After Button Is Clicked?

Nov 15, 2011

when I click on a button, it should display below the button a random randomStrings(AAA, AAB, AAC, AAD, or AAE). The problem is that when I click on the button nothing is being displayed. Instead it just re-opens the web page I am on.

How can I get it so that when I click on the button, a randomStrings appears at the bottom.

question 2 is that in the future I want the randomStrings to display AAA, AAB, AAC ... all the way to ZZZ. Is there a shorter way to display the randomStrings than just AAA, AAB, AAC and so on.

Below is my code

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Create a Session</title>
<script type="text/javascript">

[Code].....

View 1 Replies View Related

Why Does It Sometimes Display 'undefined' - When Click On Button - Random String From RandomString Variable Appears Below Button

Nov 16, 2011

What happens is that when I click on a button, a random string from the RandomString variable appears below the button. e.g I click on the button and it displays 'AAB' and then if I click on the button again it may display 'AAE' and etc.

The problem is that sometimes it displays 'undefined'. I don't wanit 'undefined' to appear but why does it sometimes display 'undefined' rather than a Random string.

Below is the code:

View 7 Replies View Related

Random Photo + Rotation Query - Continue From The Random Image And Change To The Next Every 3 Seconds?

Aug 31, 2011

I'm trying to use Javascript to have an array of images that load randomly AND work in a slideshow manner so change every 3 seconds (in a logical order). The code I have below presents a random image but how do I get them to continue from the random image and change to the next every 3 seconds?

<script language="JavaScript">
images = new Array(3);
images[0] = "<a href = 'photo1.html'><img src='images/photo1.jpg' alt='Photo 1'></a>";
images[1] = "<a href = 'photo2.html'><img src='images/photo2.jpg' alt='Photo 2'></a>";
images[2] = "<a href = 'photo3.html'><img src='images/photo3.jpg' alt='Photo 3'></a>";
[Code]...

View 4 Replies View Related

Prevent Repeating In A Random (Math.random) Array?

Aug 6, 2009

I've looked for a solution to this issue, but it seems like a little different scenario than other situations. I made a system for generating friend requests on Facebook. I have a grid that is 6 x 3, for a total of 18 cells. Each cell has a picture in it, and the picture is linked to the Facebook friend request page. My problem is that since each cell is populated at random from the array, I'm getting lots of repeats. For example, some picutures are in 5 cells, and some are in none. I'm trying to figure out how to make it so that once a picture is used once in the grid, it does not get used again in the same grid.I still want every cell filled at random on each page load, I just want to prevent the repeating.

Here's my current code:
<script type="text/javascript">
var vip_list=new Array(
new Array('http://profile.ak.fbcdn.net/v225/1616/88/s1220771654_2158.jpg','http://www.facebook.com/addfriend.php?id=1220771654'),
new Array('http://profile.ak.fbcdn.net/v223/1233/29/s904885342_9055.jpg','http://www.facebook.com/addfriend.php?id=904885342'),

[Code]...

View 6 Replies View Related







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