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


ADVERTISEMENT

Displaying Random Content On Other Websites

Nov 13, 2009

I have a simple script for showing my content (pictures) on other websites, but it generates the content by reading the users date (1-31), and because of that can show only certain amount of content/pictures (31) on a mountly bases. Can I edit this simple script to randomize the way the content is being displayed, so I'll be able to display a greater number of content? Example of the way the content is displayed: [URL]

Code that displays the script:
Code:
<script language="JavaScript" src="[URL]"></script>
Script:

Code:
var msg = new Array();
Stamp = new Date();
today = Stamp.getDate(); .....

function writeTip() {
document.write(msg[today]);
}
document.write(msg[today]);
document.write('<br>[<a <a target=_blank href="[URL]</a>]');

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

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

Random Image Displaying

Sep 7, 2005

i want Random image displaying script tutorial or code:

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

Displaying The Same Image A Random Number Of Times?

Mar 7, 2011

I'm trying to display the same image several times using javascript. It can range anywhere from 0 to about 50. I'll also have its' location determined by the user click and each image will timeout after a short period of time. I figure i'll have to create a new object for each image that is added and remove it after it times out, but my problem is I dont know how to tell the HTML code inside the <body> tag to display the same image for each click I make.

View 4 Replies View Related

Displaying Content From One Site On Another

Sep 24, 2009

You've all seen it before banner codes/rss feed displayers/twitter feeds/etc. All you do is copy and paste a <script src="[URL]"></script> somewhere on your website and it retrieves the html from the remote server and displays it on your site. I have a back end php page that pulls the required information from my DB based off a userid passed to it i.e.:
mywebserver.com/display.php?id=xxxx
Is the javascript just a simple ajax call to my php page passing straight on the userid passed to it or is there something more complex to it? I was always under the impression you couldn't do remote ajax calls to a page on a different server, which if I get this right a script off my server included on another domain becomes a member script of that domain and not my own?

View 17 Replies View Related

Displaying Content One First View Only

Feb 7, 2007

I have content inside a DIV that I want to display only the first time the page is viewed. I'm assuming this can be done with a cookie and javascript with little difficulty.

So basically it needs to write the cookie and the code for the DIV on the first load and then anytime that person returns to the page, the source for the div is omitted.

I've been researching this for a while but just am not getting anywhere.

View 1 Replies View Related

Drop Down Box Content Not Displaying?

Jan 4, 2011

get the information selected from the drop down boxes in my form to display in a pop up. The text field and text area information diplays fine. Can anyone tell me why this isnt working?

JavaScript....

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function displayHTML(form) {

[code]....

View 2 Replies View Related

JQuery :: Loading Content Before Displaying?

Oct 19, 2008

I'm fairly new to JQuery and am trying to get my menus to load all the images before it tries to fade in. I am passing categoryid to an external php page which gets the relevant data from the database, and then displays it in the right div element.

[Code]...

View 2 Replies View Related

Displaying Dynamic Content With Lightbox?

Apr 19, 2011

basically I have the following code:

<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display ='block'">View Availability</a>

This pops up a divs with a black alpha background, so that it appears the new content is displaying over the top of the current content. This all works fine, however the content I am displaying in the top level div is (or should be) dynamic.In order for the content to be useful I need to grab the id.Normally I would simply do this:

<a href = "url.php?uniqueidentifier=<?php echo $row['id'];?>" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display ='block'">View Availability</a>

However what happens in this instance is that the page loads with the javascript and the id in the url but it then disappears...

View 14 Replies View Related

Displaying Content Specific To Day Of Week?

Jun 24, 2009

I'd like to put a script on the home page of one of my sites that automatically rotates content for a specific day of the week.

You can see the site HERE.

I'd like to take the first story in the NEWS & EVENTS section and make it change with each day of the week to match the corresponding stories in THIS PAGE.

I'd like to do this all with Javascript rather than server-side includes. Unfortunately, I know very little Javascript.

View 6 Replies View Related

Displaying Content From Array Into Textarea?

Mar 19, 2009

displaying content from array into textarea

View 4 Replies View Related

JQuery :: Displaying Hidden Div Content Into Target Div?

Apr 21, 2010

1) I have a series of divs embedded into a page, sort of like an FAQ setup. Each has a unique id like id="service1" etc.

2) i'm using an unordered list with each li being a hyperlink to the div id's

3) the div's are set up as name anchors ( <a name="service1">Service One</a. ) so I can hyperlink to them via the <a href="#service1">Service One</a> method

4) There's 22 divs and they need to be hidden until summoned. Therefore, I set $('.service').hide(); to make them all disappear.

Now, where i'm stuck is in how to summon them individually and have them appear when the appropriate list hyperlink is clicked. I'm using:

$('.servicelist a').click(function() {
var toLoad = $(this).attr('href');
}

So it's telling it to load the info found at the appropriate link. This is where i'm stuck. I need help on

1) how to 'unhide' the proper div id containing the related data

2) how to point it to the right location in the page (target div)

View 4 Replies View Related

JQuery :: Safari Displaying/hiding Content?

Sep 28, 2010

I have enabled a hover() event on a DIV that includes an H2 element that is always displayed and a child DIV that needs to be shown/hidden. This code works wonderfully on Firefox and IE. However, it's not working in Safari (I have not tested Opera or Chrome yet)Here's my (very simple) code:

jQuery("div.category-text").css("display","none");
jQuery("div.category-item").hover(
function() {

[code].....

View 1 Replies View Related

Alert Box Displaying Fetched Content In Many Lines

Oct 27, 2011

I'm new here and I have tried to search the forum, but there was nothing fitting to my problem.

I would like to display content in an alert box. Sounds simple, but the content is fetched immediately, so I have no influence on that[code]...

This responseText is quite long and I need to display it in more than 2 lines.

Im doing some security research for my master thesis and am a JacaScript newbie

View 6 Replies View Related

Displaying Dynamic Variable Content (String T2)

Feb 15, 2009

I'm new to javascript and still trying to learn my way around. Below is my code

<script type ="text/javascript">
var a1 = "2";
var t2 = "hello world";
var total = ("t" + a1);
alert(total);
</script>

That code will display the string "t2" rather than the value of the variable t2. How do I make javascript display the value of the variable rather than the string?

View 5 Replies View Related

Displaying Content Based Upon Internet Connectivity

Aug 13, 2010

I have a site that can be downloaded and run on a closed network (not needing an active Internet connection). I'd like a page that displays live data to a user with Internet connectivity (I can do this) but display "canned" data when the user is without an internet connection...and this difference in page display is transparent to the user. I know this can be done with php but the user without Internet connectivity will likely not be able to run php locally so the page must be an .htm file. I there a javascript somewhere that does this?

View 1 Replies View Related

Displaying Hidden Content When Page Loads.

Oct 23, 2005

The content of my webpage is all contained in hidden divs. These divs are shown when a link in the nav bar is clicked. At the moment, ALL divs are hidden on page load, only the nav bar is visible. Is there a way to have one of the divs visable when the page loads? i.e the 'home' page.

function init(){
if(document.getElementById && document.createTextNode){
var mn=document.getElementById('nav');
var as=mn.getElementsByTagName('a');
for (var i=0;i<as.length;i++){
as[i]. false}
as[i]. false}
}
hidem();
}}

function show(l){
hidem();
var id=l.href.match(/#(w.+)/)[1];
document.getElementById(id).style.display='block'
}

function hidem(){
for (var i=0;i<document.getElementsByTagName('div').length;i++){
document.getElementsByTagName('div')[i].style.display='none'
}}

The function init() is called on page load.

View 4 Replies View Related

Refreshing The Random Content?

Mar 12, 2011

What would be the jQuery-based way of refreshing random content that is currently managed by PHP?

PHP Code:

$num = Rand (1,5);switch ($num) {case 1:echo '<div>Random content</div>';break;// and so on...} 

I'd like to add the option to refresh this content with jQuery. I'm not sure how this might work (I'm only an amateur coder and not familiar with JS beyond using plugins). Would it be as simple as adding an ID to each div and then somehow displaying a new div at each click of an anchor? It doesn't really need to be random: in number order would be fine. I want to keep the underlying PHP method, or a near equivalent, so that it degrades nicely.

View 1 Replies View Related

Random Content With This Code?

Apr 28, 2006

I have this script here that displays each ticker in a linear fashion. I would like to generate it so it will output my products randomly. For example, instead of: product1, product2, product3 etc.. I would like: product3, product1, product2. Does anyone know how to do this with this code? Code:

View 1 Replies View Related







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