473,811 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Random Quotes

25 New Member
Please can some-one help, I cannot get this to work.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Random Proverbs</title>
  4. <script type="text/javascript">
  5. <!-- HIDE FROM INCOMPATIBLE BROWSERS
  6. function changeQuote() {
  7.      var quotes = new array()
  8.      quotes[0] = "Laughter is the best medicine";
  9.      quotes[1] = "Never look a gift horse in the mouth";
  10.      quotes[2] = One good turn deserves another";
  11.      quotes[3] = "The early bird catches the worm";
  12.      quotes[4] = "Two is company, three is a crowd";
  13.      var newQuote = quotes[Math.round(Math.random()+quotes.length)];
  14.      document.quoteform.quote.value = newQuote[0];
  15. }
  16. var tick = setInterval("changeQuote()",3000);
  17. //STOP HIDING FROM INCOMPATIBLE BROWSERS -->
  18. </script>
  19. </head>
  20. <body>
  21. <form action="">
  22. <input type="text" size="50" name="quote" /><br/>
  23. </form>
  24. </body>
  25. </html>
  26.  
Jun 17 '07 #1
5 4066
gits
5,390 Recognized Expert Moderator Expert
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()*(quot es.length-1))];
document.quotef orm.quote.value = newQuote;
}
var tick = setInterval("ch angeQuote()",30 00);
//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 ...
Jun 17 '07 #2
Brigitte Behrmann
25 New Member
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()*(quot es.length-1))];
document.quotef orm.quote.value = newQuote;
}
var tick = setInterval("ch angeQuote()",30 00);
//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!
Jun 17 '07 #3
gits
5,390 Recognized Expert Moderator Expert
... 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 ...
Jun 17 '07 #4
gits
5,390 Recognized Expert Moderator Expert
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 ...
Jun 17 '07 #5
Brigitte Behrmann
25 New Member
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.
Jun 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2463
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 ((double) microtime() * 1000000);
4
2483
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 to code, does such s thing already exist. Thanks in advance...
23
4211
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 initialize it with the same parameter. Can this be done with JavaScript? I couldn't find anything in the documentation. Basically, what I want to achieve is to obtain always the same sequence of random numbers for the same given initialization...
4
2505
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. This works: <script LANGUAGE="JavaScript"> function makeArray(len) {
1
2423
by: -Art- (not Art) | last post by:
Is there a CSS solution to creating random quotes from a text or html file? TIA, -Art-
4
1530
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"; $quote = "I would love to change the world, but they won't give me the source code!' - Unknown";
6
2437
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 scr="http://www.just-quotes.com/wow/random.php" type="text/javascript"></script> The script "random.php" works correctly and pulls a random quote from the text file but everything I've tried fails to produce a quote in the HTML page. Help is needed!
4
1245
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 $sql = "select * from randomquotes where quote= $quote limit $quote,1"; $result = mysql_query($sql ,$db); ?> Rando Quote: <? echo ("$quote"); ?>
3
2096
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 array but have no idea on how to find out which 1 has been selected and then to generate the stats for that quote (if its even possible!!!) Have been stuck on this problem for 4 days now!! So any help would be appreciated. This is the code used...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10124
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.