[Portable Poetry ...poems for your pocket]












[The book printer - Amman]

Making Custom Books
-Getting the order from the Web

The first step in making a Portable Poetry (or any custom book) is finding out what the customer wants. The World Wide Web is a great way of doing this. Of course, it takes some work and know-how to set it up but it's definitely worth the effort.

Step 1: Customer Submits Their Order on the Web

It all begins at www.portablepoetry.com/create.htm which is the page on the Portable Poetry web site which has the task of collecting all the information about a customer's order. This page relies very heavily on JavaScript. JavaScript is a programming language which was developed by Netscape (not to be confused with Java which is an object oriented programming language developed by Sun - the fact that the names are similar is not a complete coincidence, however, though it does confuse a lot of people).

If you already know what JavaScript is then skip the next two paragraphs. On the web, JavaScript is mainly used in two ways. One way is to make Web pages "dynamic" which is really concerned with graphical and textual effects such as "rollover" buttons, pull down menus, mouse effects. You can do lots of exciting things with JavaScript which simply aren't possible with HTML on its own.

The second way JavaScript is used is for "form validation." Forms are basically similar to real world forms - using "text boxes", "check boxes," and pull-down menus, they provide a convenient way for visitors to a web site to send information to the web server . For example, a form might ask a user for their name, address, and e-mail. Once a visitor has filled in the relevant fields, they click on a "Submit" button and the form is sent directly to the web server for processing. Sometimes though, it's useful to check first that the user has filled in the form correctly before it's actually sent to the web server. This is called "form validation" and is done with JavaScript. A typically example of form validation is checking that no obligatory fields have been left blank.

On the Portable Poetry order form page, Javascript is used for form validation but also to control the whole ordering process. We'll see what this entails in a moment, but first, below is a brief snippet of the JavaScript used on the portablepoetry.com/create.htm page.

//BEGIN VerifyOrder1
function VerifyOrder1() {
var frm = order.document.forms[0]  //for shorthand
var d = order.document // for shorthand
var numberofpoems = frm.elements.length - 1
var numberofpoemsselected
if (totallines > maxlines){
alert ("You still have too many lines chosen for your selection. 
You need to modify your selection before proceeding to the next stage 
- press the back button on your browser")
else {
//fill up the array that will contain the selected poems
//first, in case it's already been filled 
(because the user pressed the back button on their browser), empty the array
SelectedPoemsArray = new Array()
//now repopulate the SelectedPoemsArray
var j = 0
var i = 1
while ( i < numberofpoems) {
if (frm.elements[i].checked == true){
SelectedPoemsArray[j] = PoemArray[i-1]; j++;}
//END VerifyOrder1


fig 1: some JavaScript from the create.htm page

In all there are about 500 lines of JavaScript like this "driving" the various order form pages. For example, one Javascript function called "CalculatePages" (not shown above) keeps track of the number of lines in a customer's custom book so that the poems they select will fit into the book size, while another one, VerifyOrder1(), does basic form validation and keeps track of all poems currently selected by a user . There are lots of other functions, all perfoming specific taks - JavaScript is the quickest way of doing all this.

The user can customise their book in 3 ways. The first is the choice of poems which they can either manually select one by one or use a set of "pre-select buttons" (driven by, you guessed it, JavaScript) to have poems automatically selected for them by theme. The size of the booklet is also customizable - 16, 32, or 48 pages. Finally the user can decide on an optional dedication which appears on the book fly leaf. Once the user is happy with what they've entered on the form, they select the "Submit" button on the bottom of the page (encircled below) and their order is transmitted to the portablepoetry.com server for processing.

[customer order form]

fig 2: the portablepoetry.com order form

Now select "NEXT" below to see what happens to the form after it's transmitted to the server.



Copyright 2001,
The Portable Poetry Company