Run-time Generation of JavaScript Code by Perl CGI Programs
Stephen B. Jenkins · 2001
Run-time generation of JavaScript code by Perl CGI programs is a technique that has been used with considerable success at the Aerodynamics Laboratory of the Institute for Aerospace Research, National Research Council of Canada. After a brief introduction to the basic concept of dynamic code generation and its role within the data acquisition, data display and test-control software of the 2m x 3m wind tunnel, four specific examples will be presented each highlighting a different application of the technique. The first and simplest example will show the generation of trivial one-line JavaScript programs. The second example will show the run-time generation of JavaScript functions that modify groups of HTML checkbox elements. The third example will cover form validation in the browser, complete with pop-up alert boxes and dynamic images to prompt the user. The final, and most complex case, will show the creation of JavaScript code that produces dynamic behavior in HTML forms. These examples not only demonstrate the primary benefit of the technique – a more interactive user interface – but also show the secondary benefits: reduced load on both the web-server and web-client computers.