[prog] simple HTML form

Jacinta Richardson jarich at perltraining.com.au
Sun Dec 10 11:41:47 UTC 2006


Chris Henderson wrote:

> Is there any easy way of doing this in HTML? I really don't want to use
> anything else other than HTML if I can help it.

Nope, there's no way of doing this just in HTML.  HTML is stateless, which means 
that it, itself, cannot hold state.  You have two possible options:

	1) you can use Javascript.  The javascript can then either just replace the 
form defaults with the selected values (but not remember them) or it can store 
the selected values in a cookie and store from there.  Be aware that not all 
people allow javascript to run, and of those who do, not all allow it to create 
or edit cookies.

	2) You can use something on the web server to either echo back the selected 
values, or to store them for future reference.  These are called CGI programs. 
CGI programs can be written in pretty much anything (even shell!) but common 
languages are Perl and PHP.

Although these options are superficially similar, the big difference is that 
Javascript runs and stays on the client side, while CGI scripts are run and stay 
on the server side.  This means that you can use the Javascript option even when 
your hosting provider only allows static HTML pages.  If you can work with CGI 
scripts though, you may find that in the end they allow you to fulfil your needs 
more easily.

Good luck!

	J


More information about the Programming mailing list