JavaScript

PERL is a great language for doing cool things on the server side, but sometmes you need to do something on the client side that won't force a refresh of the page and its subsequent delays. In those situations, JavaScript is the way to go.

On the search form

This project uses JavaScript in two places to improve the user interface. The first is on the Search page. When you click either of the buttons Easy search or Advanced search, the page hides one form and shows the other. The forms have a hidden form field that indicates which form it is, so even though both forms use the same PERL file for processing, the code can tell which form got submitted. JavaScript is what enables us to show or hide one section of HTML in prefence to another, in response to the user's action.

Viewing search results

The second place I used JavaScript is on the search results page. You can't see this occurrence unless you actually perform a search operation from the search page. After you do a search, there will be two buttons at the top of the page, Show extras and Hide extras. Extras is a free-form field in the database, which allows the entry of extra information that doesn't fit the other standardized database fields. Because this free-form information could be quite long, if we try to add it to a column at the end of the HTML table, the whole display will get compressed and messed up.

So, instead, I display the Extra information on a separate line in the table, and these buttons let you turn the visibility of that extra line on and off. It's easier to scan the table if the extra information is not visible, but if you've found what you're looking for and you need to see that extra information, these buttons let you do that. Again, turning the visibility on and off is done with JavaScript.