This is a discussion on "Problem with displaying random quotes from a function" within the JavaScript Forum section. This forum, and the thread "Problem with displaying random quotes from a function are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Problem with displaying random quotes from a function
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Problem with displaying random quotes from a function
Hello,
I'm very close to finishing this javaScript code and HTML, but I've got an annoying problem. The webpage is supposed to look something like the picture (click the link): http://www.webdeveloper.com/forum/at...6&d=1197038753 It basically asks the user simple multiplication questions, and when the user types in the answer, it either comes up with an alert window displaying a message like "Correct, well done" or "Sorry, try again". I have managed to randomly generate the multiplication questions, but pressing the button to check the answer comes up with nothing. It is supposed to display randomly one of 4 quotes for when the user gets the question right, or one of 4 when the user gets it wrong, using the window.alert method. Now I'm very new to Javascript, so its probably a small mistake. I have written the functions necessary to pick a random quote and display it, but when I call the function from the function "buttonPressed", no window alert comes up. What am I doing wrong? My Code So Far:
Last edited by Lchad; Dec 8th, 2007 at 14:16. Reason: took out link... not allowed. |
|
|
|
|||
|
Re: Problem with displaying random quotes from a function
Your problem is here:
Blake. |
|
|||
|
Re: Problem with displaying random quotes from a function
Hey thanks, that fixes one problem, the quotes are now coming up when the button is pressed!
Although, it is only selecting one of the quotes each time the button is pressed. IE: "Correct well done" for the right answer, "No, please try again" for the wrong answer. It doesn't seem to be randomly selecting any of the other quotes Is there any way to fix this? |
|
|||
|
Re: Problem with displaying random quotes from a function
Add the lines in bold to the following statement:
This will reset the variable each time by choosing a random number every time the script is run instead of just once. You can also delete the bold lines from above the statement. They are just extra code. e.g.
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem: onClick Function | mihirc | Web Page Design | 16 | Jul 28th, 2007 11:20 |
| Problem with random margin in IE? FF OK | bobfish | Web Page Design | 2 | Jul 4th, 2007 08:34 |
| Function parameters that include quotes | loorp | JavaScript Forum | 7 | Sep 17th, 2006 04:18 |
| Function for Displaying Month | chlad | Classic ASP | 1 | Sep 2nd, 2006 16:52 |
| XSL Displaying Problem | ivan | Other Programming Languages | 0 | Nov 23rd, 2005 01:20 |