ppk on JavaScript - the example scripts

This page contains information about the example scripts.

Back to the Book homepage.

Line numbers

The majority of the code examples in the book come from the example scripts. I've done my best to annotate these code examples with line numbers, so that you can easily find and study the complete code. You can download the ZIP file that contains the example scripts in .txt format, including the line numbers. If you want to print them, I advise you to select Landscape format.

The line numbering system is not perfect. I frequently made minor changes to the scripts while I was writing the book, and it was only in May, when I started on the final version, that I froze the example scripts so that I could start adding the line numbers to all code examples.

Unfortunately I made a few slight errors during this freezing. For instance, line 105 of Form Validation is spurious: it occurs between two lines with closing curly braces }, and in general I never use an empty line in such a place. When I noticed this error, I had already annotated the majority of the example scripts and I didn't want to go through six chapters to check all Form Validation line references. Therefore the error has not been removed.

Besides, I'm absolutely certain I made a line numbering mistake somewhere in the book. I just haven't found the mistake(s) yet.

The example scripts

Below you find the eight example scripts, as well as links to the working version and the .txt version with line numbers. See the Introduction for a general description of the scripts.

The book contains three general comparisons of all the example scripts:

Textarea Maxlength

Working version
Printable version
Line by line explanation.

This script operates in all my Blog pages to restrict comment length

Usable Forms

Working version
Printable version
How to use the script in your own sites.

This example script shares a page with Form Validation.

Form Validation

Working version
Printable version

This example script shares a page with Usable Forms.

Working version
Printable version

This example script shares a page with Edit Style Sheet.

Edit Style Sheet

Working version
Printable version

This example script shares a page with Dropdown Menu.

Sandwich Picker

Working version
Printable version

XMLHTTP Speed Meter

Working version
Printable version

Live version. I wrote the script for the ISP Wanadoo, but meanwhile it has changed its name to Orange; and the graphic design of the page has changed. The script still works, though.

Site Survey

Working version
Printable version survey.js
Printable version popup.js

This is the only example script that consists of two JavaScript files: survey.js for use in all pages of the host site; popup.js for use in the popup.