Please can some-one help, I cannot get this to work. -
<html>
-
<head>
-
<title>Random Proverbs</title>
-
<script type="text/javascript">
-
<!-- HIDE FROM INCOMPATIBLE BROWSERS
-
function changeQuote() {
-
var quotes = new array()
-
quotes[0] = "Laughter is the best medicine";
-
quotes[1] = "Never look a gift horse in the mouth";
-
quotes[2] = One good turn deserves another";
-
quotes[3] = "The early bird catches the worm";
-
quotes[4] = "Two is company, three is a crowd";
-
var newQuote = quotes[Math.round(Math.random()+quotes.length)];
-
document.quoteform.quote.value = newQuote[0];
-
}
-
var tick = setInterval("changeQuote()",3000);
-
//STOP HIDING FROM INCOMPATIBLE BROWSERS -->
-
</script>
-
</head>
-
<body>
-
<form action="">
-
<input type="text" size="50" name="quote" /><br/>
-
</form>
-
</body>
-
</html>
-
5 4053 gits 5,390
Expert Mod 4TB
hi ...
have a close look at the following (working) version of your code:
[HTML]<html>
<head>
<title>Random Proverbs</title>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
function changeQuote() {
var quotes = new Array()
quotes[0] = "Laughter is the best medicine";
quotes[1] = "Never look a gift horse in the mouth";
quotes[2] = "One good turn deserves another";
quotes[3] = "The early bird catches the worm";
quotes[4] = "Two is company, three is a crowd";
var newQuote = quotes[Math.round(Math.random()*(quotes.length-1))];
document.quoteform.quote.value = newQuote;
}
var tick = setInterval("changeQuote()",3000);
//STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
<form name="quoteform" action="">
<input type="text" size="50" name="quote" /><br/>
</form>
</body>
</html>
[/HTML]
you missed the name of the form, the rnd-number was wrong, newQuote is the array-value already, new Array()! (you may use [] for that) ... testing your script in firefox with the firebug-extension shows you most of the errors ...
kind regards ...
hi ...
have a close look at the following (working) version of your code:
[HTML]<html>
<head>
<title>Random Proverbs</title>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
function changeQuote() {
var quotes = new Array()
quotes[0] = "Laughter is the best medicine";
quotes[1] = "Never look a gift horse in the mouth";
quotes[2] = "One good turn deserves another";
quotes[3] = "The early bird catches the worm";
quotes[4] = "Two is company, three is a crowd";
var newQuote = quotes[Math.round(Math.random()*(quotes.length-1))];
document.quoteform.quote.value = newQuote;
}
var tick = setInterval("changeQuote()",3000);
//STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
<form name="quoteform" action="">
<input type="text" size="50" name="quote" /><br/>
</form>
</body>
</html>
[/HTML]
you missed the name of the form, the rnd-number was wrong, newQuote is the array-value already, new Array()! (you may use [] for that) ... testing your script in firefox with the firebug-extension shows you most of the errors ...
kind regards ...
Will do, thanks so much for the help, you have no idea how lost and frustrated I feel.
I found a download for Firefox, but have no idea how it works. Any tips as the help guide does not explain how to test one's code! ..... now I really sound doff, but this is all very new to me!
gits 5,390
Expert Mod 4TB
... firefox is a webbrowser based on the gecko-rendering-engine that is also used by netscape, mozilla, ... browsers. simply install it and use it like ms internet explorer ... it is nearly the same ... there is nothing more to mention about it ... you will see.
firefox is 'extensible' that means there are some extensions (consider it as kind of plugins) that you may download and install to it ... so go to firefox's menu and go to 'extras' -> 'add-ons' - a popup appears. you click 'extensions' on top of it ... and then you click 'download extensions' (right bottom corner) ... you will be directed to the extensions-download-page ... search for firebug and use the install-link provioded there ... that installs firebug ... and next time you start firefox you notice a little symbol in the right bottom corner of it ... click it and enable firebug ... you will see what to do! ... then load a page with your script ... perhaps with an error! ... you will see what firebug displays and thats the hint for the error ... play with firebug ... it will be of great help to you ... i promise ;)
kind regards ...
gits 5,390
Expert Mod 4TB
if you don't want to use firebug ... as an alternative you may use the javascript-console ... that already comes with firefox ... 'extras' -> 'Error-Console' ... there the javascript errors will be displayed too! ... its a little bit more simple ... ;)
kind regards ...
if you don't want to use firebug ... as an alternative you may use the javascript-console ... that already comes with firefox ... 'extras' -> 'Error-Console' ... there the javascript errors will be displayed too! ... its a little bit more simple ... ;)
kind regards ...
Will give it a try. Thanks again.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JDJones |
last post by:
I'm using the following to generate a random quote on a PHP page and it
works fine:
<?php
$quotes = 'quote #1';
$quotes = 'quote #2';
$quotes = 'quote #3';
$quotes = 'etc...';
srand...
|
by: Papa Legba |
last post by:
I have huge page of links, to whcih I am currently adding. I would
like to add a "random link" button which would parse the current page,
extract all URLs then load a random link.
Before I start...
|
by: Thomas Mlynarczyk |
last post by:
I remember there is a programming language where you can initialize the
random number generator, so that it can - if you want - give you the exactly
same sequence of random numbers every time you...
|
by: lharby |
last post by:
I'm hoping this is very simple. I am currently using a random quote
generator on our intranet.
I have 17 quotes, when I add in an 18th and change the makeArray
number the code seems not to work....
|
by: -Art- (not Art) |
last post by:
Is there a CSS solution to creating random quotes from a text or html
file?
TIA,
-Art-
|
by: orbstra |
last post by:
<?php
//Variables
//Quotes
$quote = "'If at first you don't succeed; call it version 1.0' -
T-Shirt";
$quote = "Microsoft: 'You`ve got questions. We've got dancing
paperclips.' - Unknown";...
|
by: RTB |
last post by:
I've been trying to replace my old PHP/iframe random quotes script with a PHP/javascript without success.
http://www.just-quotes.com/wow/random.php
<script...
|
by: Breana |
last post by:
Ok, i want to make a sql statment select from a table, random quotes and display a random one each time the page is loaded!
I got it to connect, but it keeps selecting all of them...
<?php ...
|
by: keegan90 |
last post by:
Hi there, first post so hope it goes well :)
Im trying to generate statistics on which quote will be displayed each time i refresh the page.
I've stored 10 famous quotes in the $famous_quotes...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |