Web Workshop issue 155.

The Project That Would Not End is featured this month, as the Millennium Edition of my DHTML-powered Quiz application, packed with new features, sees the light of day. You can play it, create your own question files, and customise the quiz sound and graphics. Also, see JavaScript in step-by-step action selecting sequences of unique random numbers, check for yourself how random the randomiser really is, and make your fortune (perhaps) with our highly practical random number-generating application!  Paul Stephens


Quiz
Play the quiz (Extra Rock Questions)
Create your own quiz

Random selections
Animated Demo
How Random Is Random?
A Practical Application
Reference
Microsoft
Paul's Pages
Last month I just managed to beat the SuperCD deadline with a heavily remodelled, IE5-only version of issue 129's Quiz system. Since then I've converted it back to IE4 compatibility, added sound effects and a high scores table, and generally brought it up to Service Pack 1 status. 

I also did some serious internal 're-architecting', dropping cookies and  IE5 data persistence in favour of a faster and simpler frame-based method of passing data between the quiz suite pages. Cookies came back, however, for my client-side high-scores table subsystem, although even then the new 'parent frame' design came in useful for sharing cookie-handling JavaScript functions between pages. One up to frames, which shows that 'old' technology  can still have a lot to offer!

This month's Web Workshop (in PC Plus issue 155) has details of the frame-based data and code sharing system, as well as a surprisingly simple way to play incidental sound effects in IE4, and the surprisingly complex technique required to pre-download sound files from a web server so that they're ready to play. I've also described how the Quiz's question timeout system works by firing off setTimeout() countdown timers, which cancel the current question if they reach zero, but can be interrupted by the user choosing an answer. 

Here at www.paulspages.co.uk you can play the quiz  (complete with a 1960s Rock question set not on the PC Plus SuperCD), and also get details of how to customise the quiz, by adding your own question files and changing the sound effects and graphics.

If you put your own version of the quiz online, let me know, so I can create a page of links to quiz sites!

Random Selection Special!

Random question selection (also described in Web Workshop) is one of the major - and necessary - improvements in my DHTML-powered Quiz. Generating random numbers is simple enough in JavaScript (just use the Math.random() method), but it's another matter altogether to select numbers at random from a given range (say 1 - 50), with no number appearing twice. 

This kind of controlled random selection is quite a useful technique, whether for choosing questions within a round of a quiz, displaying random 'tip of the day' messages, or picking numbers to enter on a lottery ticket. In the Animated Demo you can see the principles of controlled selection in action, with a step-by-step demonstration of a JavaScript function using a lookup array to prevent the same number appearing twice. 

How Random is Random? generates 50 sets of 20 unique numbers - see for yourself how random they really are, and how quickly the randomising routines run in real life. Meanwhile the Practical Application could make your fortune (it's a Lottery number selector), but then again it might not! The Lottery page uses a self-contained set of JavaScript functions which you can paste into any page and use to generate unique random numbers from a specified range - check the source listing for the code and instructions.


Next month - create your own art gallery using Netscape/Microsoft compatible Dynamic HTML! Until then, happy authoring!


Back to Menu