Random Script Without Repeating?

Nov 17, 2011

I've found this code elsewhere and am currently using it to load 5 random pages that automatically refresh to another in the array after 10 seconds. This works great. But is there a way of altering this code so it doesn't repeat any of the pages - atleast until it's displayed each page once?

At the moment it can display 'page5' 3 or 4 times before I even see 'page2' for example - which is annoying!. [code]...

View 8 Replies


ADVERTISEMENT

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

Non Repeating Four Random Images

Oct 11, 2010

I want to display 4 random images and I would like to get them to NOT repeat themselves. So if image one is randomly selected as "aceclubs.png" I don't want image two to be the same and so on for the other images. This currently the code I'm using right now. I've been duplicating this function with different names for each of the 4 images. However it sometimes produces two of the same image and I don't want that.

function random_ace(){
var cardace = new Array(4)
cardace[0] = "aceclubs.png";
cardace[1] = "acediamonds.png";
cardace[2] = "acehearts.png";
cardace[3] = "acespades.png";

var randomace = Math.floor(Math.random()*cardace.length);
var ace = cardace[randomace];
card1.src=ace
}

View 24 Replies View Related

Random Non-Repeating Images Script

Dec 18, 2009

Random non-repeating images script. You can see an example at [URL]. Refresh and you'll see the PS3 boxarts on the top left will show randomly, with no repeats.

In your html page
in head tag
<style>
img.boxart{
margin:0;
border: none;
display:block;
float:left}</style>
<script type="text/javascript" src="ps3boxart.js"></script>

In body tag (place whereever in the body you want the pictures to show)
<script type="text/javascript">
randomorder(ps3ba, '')
</script> .....

function randomorder(targetarray) {
var randomorder=new Array()
var the_one
var z=0
for (i=0;i<targetarray.length;i++)
randomorder[i]=i

while (z<targetarray.length) {
the_one=Math.floor(Math.random()*targetarray.length)
if (targetarray[the_one]!="_selected!"){
document.write(targetarray[the_one])
targetarray[the_one]="_selected!"
z++
}}}

Then obviously, you would use this as a baseline and change your .js file name to whatever your pictures are for, like ads.js or whichever. Change the links in ahref to whereever you want each page to link. Change the image locations in img src to whereever your images are saved. Remember, where it says var z=0... this is where you hide extra random images. For example, my 200px cell only fits 9 22px wide images (they equal 198px). I only have 9 in my ps3 boxart image folder. If I want 50 in there... I would upload the pics to the folder with the other ones, add them to the list in the .js file. Such as ps3ba[9]=, ps3ba[10]=, etc. up to [49] (49 + 1 for [0] = 50). Then since I can only fit 9 in my cell, I would have to change the variable to var z=41 (to hide 41 of them and only show 9).

View 1 Replies View Related

Random Images / Links Without Repeating

Mar 9, 2010

I have a web page that contains a bunch of advertisements. What I need to do it randomly shuffle these images each time the page is refreshed. I cannot have any repeating ads.

View 5 Replies View Related

Generate Random Numbers Without Repeating [js]?

May 14, 2011

I got this code and it generates random numbers but with repeating code...

View 3 Replies View Related

Displaying Random Text Without Repeating The Content?

Jan 26, 2011

I'm using the script below in a custom HTML to generate a random line of text (not with the text shown here). This works fine BUT; I want it to go randomly through the WHOLE list without repeating lines that already have been printed. As it is now, a line of text might be printed several times in a row, which is a little annoying. I'm using a refresh button for generating a new line of text.

How can I just make it display in the order shown and just re-arrange the content so it seems random to the user? Random would the best though...

<script language="JavaScript">
<!--
var r_text = new Array ();
r_text[0] = "All the leaves are brown";

[Code]....

View 6 Replies View Related

JQuery :: Function Keeps Repeating / Why Is So?

Jul 16, 2010

It is a beginners problem I'm sure but I'm making a menu and when hovered, the submenu appear. However, when moving the mouse the submenu keeps fading in and out a few times. Why? Can I stop the function from repeating itself over and over? [code]...

View 3 Replies View Related

Creating / Repeating Styles ID On The Fly?

Sep 7, 2010

I displaying mysql data in a webpage using div's and tables. Each row of data has 4 div's, and a certain style. The 4 div's will be repeated for each row of the query result. I want to repeat the style for each set of div's as they are created. I imagine this would/could be achieved using and array of style id's such as:
ID1a, ID1b, ID1c, ID1d
ID2a, ID2b, ID2c, ID2d
etc,
etc....
How can I create/repeat these style ID's as I create/repeat the div's?

View 1 Replies View Related

Getting A Repeating Countdown Timer

May 27, 2009

I'm making a webpage for a school project and I need modifying this timer here: [URL]I want it to countdown from 48 hours, and as soon as it counts down, I need it to reset. I need an endless countdown of 48 hours.

View 37 Replies View Related

Taking Out Repeating Information

Feb 6, 2006

I have an object that looks like this:

"Jan 2005 120"
"Jan 2005 123"
"Jan 2005 126"
"Jan 2005 128"
"Jan 2005 130"
"Jan 2005 132"
"Feb 2005 135"
"Feb 2005 143"
"Mar 2005 120"
"Mar 2005 123"
"Mar 2005 126"
"Jul 2005 128"
"Jul 2005 130"

I want to output:

Jan
Fed
Mar
Jul

How can i most efficiently accomplish this?

View 4 Replies View Related

Repeating An Entire Program?

Nov 16, 2009

How would I go about repeating an entire program? I know it's a loop, not sure which one. I've tried a while loop.For example:

Q: Do you want to play a game of Rock, Paper, Scissors?

A: Yes -Program Runs-

Now, how would I have it ask if the user wants to play again?

Q: Do you want to play a game of Rock, Paper, Scissors?
A: Yes -Program Runs-

Q: Do you want to play again?
A: Yes -Program runs again-

Q: Do you want to play a game of Rock, Paper, Scissors?
A: Yes -Program Runs-

Q: Do you want to play again?
A: No -Program terminates-

View 3 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

JQuery :: Ajax Request Keeps Repeating?

Nov 29, 2011

i am making a request using Ajax (JQuery) and it keeps repeating the request, it almost seems like it is inside a loop even though it is not inside a loop.

jQuery.ajax({
type: "GET",
cache: false,
url: "<?php echo Yii::app()->request->baseUrl; ?>/member/updatememberinfobox/query/",

[Code]..

View 5 Replies View Related

JQuery :: Image Scroller Not Repeating?

Jul 2, 2011

var scrollSpeed = 1;
// Speed in milliseconds
var step = 1;
// How many pixels to move per step

[Code]....

View 1 Replies View Related

JQuery :: Selecting A P Inside A Repeating DIV?

Apr 28, 2009

My basic code is something like

<div class="insidepost">
paragraph 1
paragraph 2

[code].....

View 3 Replies View Related

JQuery :: Parsing Nested Repeating XML?

Mar 31, 2010

I have an xml with nested repeatingentries. I want to parse it using jquery, I have tried .find methodbut it ignores the child parent relation and consider all as child nodesI want to parse it inhierarchy like first it should show top level categories then if have nested categories and then if have products and so on.

<products>
<category>
<categoryid>2</categoryid>

[code].....

View 8 Replies View Related

JQuery :: Repeating Animations - How To Stop Them

Apr 20, 2010

I have applied the fadeIn() and fadeOut() effects to a li>ul in my html, but if the user leaves the ul briefly then re-enters it before it has finished fading out, the ul fades back in again. This can happen many times over by accident and it's very annoying.

If the user leaves the ul I want it to fadeOut() and NOT fadeIn() again until the user re-enters the parent li element.Is there a way of ensuring this? I have done a quick search for while and if/then/else functions but haven't been getting anywhere. This is what I have, very simple indeed:

$(document).ready(function() {
$(".nav ul").hide();
$(".nav li.conductor").hover(function() {

[code]....

View 2 Replies View Related

JQuery :: SlideToggle Unwanted Repeating?

Jul 23, 2009

I'm using mouseenter and mouseleave to call a slideToggle on a dropdown menu. What's bothering me though is if my mouse moves in and out of the menu a few times before the toggle animation is complete and replays the open close a few times before stopping. [URL]... Is there a way to kill the queue so that it doesn't play if the mouse is not over it anymore?

View 2 Replies View Related

JQuery :: Stop An Animation From Repeating Over And Over, Blinking?

Oct 19, 2010

each time I hover on #demo, the piece of code below works, but it will not stop doing it even if I'm not on hover, it is like it will repeat the process all the times I hovered and didn't have time to repeat it.

$('#demo').hover(function () {
$(this).animate(
{ height: 40, paddingTop: "15px"},

[code]....

View 1 Replies View Related

JQuery :: Use For Repeating Elements In Every Page Of Site?

Nov 27, 2010

I want to repeat 3 .html file in every page of my site. (header.html, footer.html and navigation.html), I read something about php's include() function. but I like to use JQuery's .ajax() or get() function. How can I do that?

View 1 Replies View Related

JQuery :: Implementing Repeating TextBox Controls

Jan 5, 2010

Let's put it this way.I have the following repeating DIVs:

<asp:TextBox ID="txtInsertComments" AutoPostBack="false" CssClass="expanding" runat="server" Width="400px" Text='<%# Bind("comments") %>' TextMode="MultiLine" />
<div id="commands" style="display: none;">
<table cellpadding="0" cellspacing="0" width="400px" id="tblCommands">

[Code].....

How do I use jQuery to determine which textbox control is being clicked and then show the div that relates to that TextBox? Again, both the textbox along with the div=command are all repeating. It could repeat more than just twice as showing in the example above. I need the jQuery to only show the div=command that the user has clicked on the TextBox for commenting.

View 9 Replies View Related

JQuery :: Passing Repeating Elements To $.post?

Sep 15, 2009

Im using $.post and have a lot of repeating elements I need to post like the cat elements in the example code below.

I could use a loop in some way to add the repeating elements rather than listing them one by one.

$.post("save.php",{
id:$('#id').val(),
save:$('#submit').val(),
name:$('#name').val(),

[Code].....

View 3 Replies View Related

JQuery :: Replacing Repeating Text On A Page?

Mar 28, 2011

I have a SharePoint page that is filled with the text string "12:00 AM" that I would like to remove, the underlying HTML is

<td class="ms-cal-workitem">
<table>
<tr>
<td class="ms-cal-monthitem">

[Code]....

View 14 Replies View Related

Repeating Blocks Into For Loop - Alert Never Show Up

May 14, 2010

I had some code that kept repeating itself over and over again, with the only variance being some named elements changing. All the named elements ended in a sequential number, so I figured I'd just put one of the repeating blocks into a "for" loop and then make that sequential number at the end of the named elements into the variable in the loop. Again, the code worked fine when copied/pasted over and over, but now it doesn't do anything. Here's one of the code snippets outside of the loop (which worked):

Code:
$(document).ready(function () {
$("#SelectDiv1").change(function() {
if ($("#DD1").val() != "0") {
$('#SelectDiv2').hide();
$('#SelectDiv3').hide();
$('#SelectDiv4').hide();
$('#SelectDiv2').show();
$.ajax({ .....

You can see there's an "alert" as the first part of the loop. That "alert" never shows up. However, if you comment out everything in the loop after the "alert", then the "alert" works. So something else in that loop is causing the whole thing to not work. I find it odd that the first "alert" wouldn't work, though, since it should be the first thing that happens before any of the other code is executed in the loop, right???

View 8 Replies View Related

Change BG Color Of The Row Repeating In Loop Dynamically Data?

Sep 29, 2011

I am having a single row which repeat dynamically. My issue is i want to make alternate colors in rows. (i.e white n gray) I can put the class for the row. but when it repeats it get the same bg color. How can i do the alternate thing.?

View 5 Replies View Related







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