Simple Random Phrase Generator

Sep 29, 2007

I haven't really used javascript before except for the odd snippet, and I was wondering if anyone can help me with a problem I have:

I need a script that chooses a phrase at random from 4 pre-defined lists of phrases, and does it all from the one page - rather than a separate page and a separate script for each pre-defined list of phrases.

I hope this is clear enough! Here is an example to illustrate what I mean:

This would be the text that appears on the webpage:

Click here for random Phrase Type 1
Click here for random Phrase Type 2
Click here for random Phrase Type 3
Click here for random Phrase Type 4

When clicking the first option, it only chooses from pre-defined list #1, the second option only chooses from pre-defined list #2, and so on.

It then displays the randomly generated phrase in one separate box, no matter what pre-defined list was chosen. (Although if each phrase has to be displayed in 4 separate boxes, that'd be ok too.)

View 1 Replies


ADVERTISEMENT

Simple Random Image And Text Generator

Mar 27, 2010

I have used the below code, found on a forum from 2006, to generate a random image on my website with a link and accompanying text.The image works fine, the link that goes with each image is fine.Problem is: the text beneath the image does not match the image and link. This seems to be generated as a separate random element. Can anyone tell me how I can make my site display image 1 + link 1 + quotation 1?

View 6 Replies View Related

Getting Random Line Generator Bug / Why Is So?

Dec 21, 2009

I have a piece of code that randomly picks a line from a preset list and displays it whenever the page is loaded. I'm using it to generate random quotes on my pages.

At the moment, there seems to be a good chance that when the page loads no quote appears at all, just a blank space.

Anyone know why this could be happening?code...

View 3 Replies View Related

Random Link Generator Within A DIV (CSS)?

Jan 3, 2010

I have a problem with a random link generator within a DIV. When I try it on my desktop it works fine, but does nothing once I upload it to the website.how to explain what happens, but here is it, more or less:The website is this: http:[url]....

Via an Ajax script, http:[url]..... is loaded into DIV "menu". Here's the script:

<script type="text/javascript">
ajaxpage('menu.html', 'menu') //load "menu.html" into "menu" DIV
</script>

Well, there's another load of stuff inside the <head> tag. You may see it from the main page source code.Anyway, if you go to the menu.html, the link generator will work there as it is intended; however, if you try it from the main page, it won't do anything. But people are not suppossed to go to menu.html. They are suppossed to load it from the index.html (I mean, plain http:url....)So, here's the link generator code:

---------------------------------
<script type="text/javascript">
function randomlinks(){[code].....

I believe this could be solved if I could target the generator to the whole window, 'cause maybe it's trying to open the new page inside the DIV. Well, I don't know...

View 1 Replies View Related

Random Link Generator A Dud?

May 24, 2010

I used the code on this website [URL]... but it doesn't work. I have 167 links and placed the code correctly but nothing. What am I doing wrong?

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

Random Number Generator Returning NaN's?

Mar 25, 2011

the script is supposed to allow the user to enter a minimum and maximum value and then enter the number of random numbers to generate between the min and max.

then it is supposed to floor these numbers and post the in a single column table. my script is writing the table correctly but the numbers arent coming through

Code:
<table border = "2">
<script type="text/javascript">
var min = window.prompt("Enter the 1st number","");

[Code]....

View 2 Replies View Related

Short Random Generator Without Having To Import Anything?

Dec 8, 2010

I need help with a code that will generate a random number or integer (from 1-9). Does anybody know of a short random generator without having to import anything?

View 1 Replies View Related

Non-repeat Random Number Generator?

Aug 14, 2011

I've looked everywhere for a random number generator which doesn't repeat. Tried loads and none have seemed to work.I'm making a quiz, 5 questions so far.This button, in html, generates the next random Q:But I need a random generator which fires them off only once. Anyone have suggestions for a non-repeating random number gen which will work? Even the one now seems to have some slight error associated with it. The one's ive tried so far haven't worked..

View 31 Replies View Related

Random Sentence Generator Using Array

Mar 29, 2010

I am taking a Javascript class and the teacher assigned this: Quote: Write a script that uses a random number generation to create sentences and name it sentences.html. Use five arrays of strings called: uppercase article (uarticle), noun, verb, lowercase article (larticle), and preposition. You will need to use the correct case for the article arrays. Create a sentence by selecting a word at random from each array in the following order: uarticle, noun, verb, preposition, larticle, noun. You can find examples of generating random numbers in both Fig. 8.6 (dice-rolling) and Fig. 8.7 (random image) of Chapter 8.

The arrays should be filled at minimum, as follows: the article array(s) should contain the articles: the, a, one, some and any. The noun array should contain the nouns: boy, girl, dog, town and car. The verb array should contain the verbs: drove, jumped, ran, walked, and skipped. The preposition array should contain the prepositions: to, from, over, under and on. If you would like to add more words, adjust the arrays appropriately.

[Code]...

View 1 Replies View Related

Configure Random Number Generator To Only Execute Once?

Feb 20, 2011

I scripted a javascript guessing game and I am not sure how I can configure the random number generator to only generate one number and then stop.code...

View 6 Replies View Related

General Random Image Generator For 6 Images?

Sep 24, 2011

including links to an image folder, for displaying 6 fullscreen images in random order without repeat for a given user?I've seen specific examples using shuffle on the site, but could anyone write a general code for any given images?

View 5 Replies View Related

Online Quiz With Random Image Generator

Nov 13, 2009

My assignment is to create an online quiz with a random image generator. I have created my online quiz using 5 linking files and everything works great. My only problem is getting the images to show up on my quiz. All I get is the filename with a red X. Which the files do show up at random when I refresh, so I know that part is working. I just don't know what I am missing to get the actual picture to show up. Please keep in mind this isn't the whole code as I have different linking files for this assignment.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 StrictEN" "[URL]">
<!-- Assignment CH10 Solution -->
<html xmlns = "[URL]">
<head>
<title>Online Quiz</title>
<script type = "text/Javascript">
<!--
var rimg = 0;
var pictures = [ "logo", "logo2", "logo3", "logo1", "cover" ];
function randpics(){
var myQuiz = document.getElementById( "myQuiz" );
rimg = Math.floor( Math.random() * 5 );
myQuiz.logo.src = pictures[rimg]+'.gif';
myQuiz.logo.alt = rimg + ' : ' +pictures[rimg];
} function checkAnswers() {
var myQuiz = document.getElementById( "myQuiz" );
if ( myQuiz.elements [ 0 ].checked )
alert ( "Congratulations, your answer is correct" );
else if the answer is incorrect
alert ( "Your answer is incorrect. Please try again" );
} end function checkAnswers
-->

View 6 Replies View Related

Random Text Generator Doesn't Work

Nov 26, 2010

i added a random text generator at a page and it doenst work!

View 9 Replies View Related

Random Password Generator In File Handling?

Jun 28, 2010

actually i am working on a project "random password generator". What basically is to be done in this project is to generate user password for the username randomly he has provided. Then, this password is to be stored in a text file in the following manner

UserName Password
ABCD JU12H6
Sdjksj HJudfdsfd

Now my problem is that every time I just try to generate a new password, either a new file is made or the heading is rewritten again and again or if I just try to change the variables true and false, then the username and password headings are not printed. Please help. If someone knows how to do this using if-else method then please tell me, how it can be done? The code is attached.

[Code]...

View 1 Replies View Related

Random Quote Generator Script (For Uni Project)?

Jul 19, 2011

I have to create a website as a project for my university course. Said course has nothing at all to do with computers really so it's really throwing us into the deep end as the majority of us have/had no interest in this particular field.

Regardless, I am creating a website that uses the Random Quote Generator Javascript that I copied from the Hotscripts website. The code details are below and my question is: is there any way I could change the formatting for each quote? For example, change quote 1 to be, say, yellow or bold and change quote 3 to be aligned right and blue? I mainly want to change the colour for each quote but having any other info on how to format it would be really helpful.

var quotes=new Array();
quotes[0] = "This is quote 1.";
quotes[1] = "This is quote 2.";
quotes[2] = "This is quote 3.";

[Code]...

View 3 Replies View Related

Random "Pronouncable" Password Generator

Jul 29, 2002

this script lists the basic elements of a word and chooses a random word structure to make the word pronouncable... or... at least 50% of them ;). I'm sure there is a way to do this to cut down on the code... but here goes anyway...

<script>

/****************************************
* *
* Random "Pronouncable" Password Script *
* *
****************************************/

var letters = "bcdfghjklmnprstvwxyz";
var vowels = "aeiou";

groups = new Array();
groups[0]="th";
groups[1]="ch";
groups[2]="sh";
// groups[3]="qu";

function generate(number) {

// randomize letters

var vowel1 = vowels.charAt(Math.floor(Math.random()*vowels.length));
var group1 = groups[Math.floor(Math.random()*groups.length)];
var letter1 = letters.charAt(Math.floor(Math.random()*letters.length));
var vowel2 = vowels.charAt(Math.floor(Math.random()*vowels.length));
var group2 = groups[Math.floor(Math.random()*groups.length)];
var letter2 = letters.charAt(Math.floor(Math.random()*letters.length));
var vowel3 = vowels.charAt(Math.floor(Math.random()*vowels.length));
var group3 = groups[Math.floor(Math.random()*groups.length)];
var letter3 = letters.charAt(Math.floor(Math.random()*letters.length));
var vowel4 = vowels.charAt(Math.floor(Math.random()*vowels.length));
var group4 = groups[Math.floor(Math.random()*groups.length)];
var letter4 = letters.charAt(Math.floor(Math.random()*letters.length));

// specify the structure of the words (in order for them to be pronouncable)
// feel free to add your own...

structure = new Array();
structure[0]=letter1+vowel1+letter2+letter3+vowel2+letter4+vowel3+group1;
structure[1]=group1+vowel1+letter1+letter2+vowel2+letter3;
structure[2]=group1+vowel1+letter1+letter2+vowel2+group2;
structure[3]=group1+vowel1+letter1+vowel2+"s";
structure[4]=vowel1+group1+vowel2+letter1+vowel3;
structure[5]=group1+vowel1+letter1+vowel2+group2;
structure[6]=vowel1+group1+vowel2+letter1;

var password=structure[Math.floor(Math.random()*structure.length)];

if (number==1) {
document.passform.passbox.value=password+Math.floor(Math.random()*100)
}
else {
document.passform.passbox.value=password;
}
}
window.onload=generate
</script>

<div align="center">

<table>
<tr>
<td colspan="2" align="center" style="font-family: verdana; font-size: 12pt; font-weight: bold;">
Random "Pronouncable" Password Generator
</td>
</tr>
<tr>
<td>
<form name="passform">
<input type="text" name="passbox" style="font-family: verdana;" onfocus="this.select()" /><br>
</td>
<td>
<input type="button" value="Generate! (Words Only)" onclick="generate(0)" style="font-family: verdana" />
<td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td>
<input type="button" value="Generate! (With Number)" onclick="generate(1)" style="font-family: verdana" />
</form>
</td>
</tr>
</table>
</div>

View 5 Replies View Related

Random Quote Generator, Make Quote In Bold?

Jun 12, 2009

Below is a Random Quote generator script I found on the net, its a great script, but I want the quote to be in bold, how is that done please?

<center>
<font color="#71025F" size="2" face="Verdana,Arial">
<script language="JavaScript">
//
var Quotation=new Array() // do not change this!

[Code]...

View 9 Replies View Related

Read Everything After A Certain Phrase?

May 1, 2011

ok so I know how to do substring to read everything before a certain phrase however is there a way to read everything after a certain phrase? Ex of what this script reads and doesent read

Alex was slain by dog

Bob was slain by cat

Alex & Bob = "Var CharName" My substring reads this in this line:
Var Charname
CharName = msg.substring(0, msg.indexOf(" was"))[code].....

View 4 Replies View Related

Search Another Site For A Specific Phrase?

Jan 19, 2009

I am looking for a way to search another site for a specific phrase.

People are linking to my site and then I have to ask them for the page where they linked and go validate that it's there. I'd like to automate this process.

View 1 Replies View Related

Grab The Keyword Phrase That Someone Used To Enter The Website

Dec 21, 2010

How can I grab the keyword phrase that someone used to enter the website and then pass that through a form? I would need to know for search engines and Google AdWords as well. Does anyone know how to do this?

View 5 Replies View Related

JQuery :: Validate: Require A Specific Word Or Phrase?

Aug 30, 2010

I want to add a simple alternative to CAPTCHA on a form by adding a required text input - e.g.Type the word "jquery":How do I add a rule requiring a specific value?

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

Color Generator

Apr 1, 2006

My form allows the user to assign colors to different fields that are then
used in a java piechart/barchart applet as the colors of the different pie
sections/bars. It can be tedious assigning colors even with my color pic
tool especially as the number of different colors increases. The application
is data driven so it may end up requiring any number of colors up to about
100. Of course you want the colors to be as different as possible.

It would be nice to have an "Auto" button to click that will then fill out all the
color fields with a properly generated set of colors - that is colors that
are as different from each other as possible. Random colors won't do as you
might end up with very similar colors. Is such a program possible?

View 4 Replies View Related

Name Generator Won't Validate

Jul 6, 2006

I'm building a name generator where a person puts their name in and gets a different name out. I've set it up so you have to put in something.

When I test it it tells me I haven't put a name in, but obviuosly I have. I can't see where the code is wrong. Here are the relevant bits, I've cut out all the other code:

View 12 Replies View Related







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