[prog] perl woes...

Wolfgang Petzold petzold at villa-chaos.de
Sun Jun 1 14:23:10 EST 2003


Hi, Patricia!

> > > [...] I'd like the choices the user makes in the first two lists to
> > > be able to be plugged into the select statement for the third list,
> > > so the third list will only have data according to the first two
> > > choices.

> Thanks for this; I'd sort of come to the same conclusion. Anyway, we've
> messed with the database design some, to make it unneccessary for the
> first part - if it gets too difficult, we'll just have to do that again!

Now I wanted to know myself. And surprisingly, it wasn't as complicated as
I had expected. :-)

JavaScript is able to access your named tags in the HTML page, and it
provides various methods for different tags. Among them is a method
"submit()" for forms. So, the core part is something like:

---------------------------------------------------------------------------
my $cgi = CGI->new();
# [...]
my $selfurl = $cgi->self_url();
print << "EOT";
<form action="$selfurl" method="get" name="select_1_and_2">
        <select name="select1">
                <option value="--none--" selected>--please choose--
                <option value="first">first option
                <option value="second">second option
                <option value="third">third option
                <option value="fourth">fourth option
        </select>
        <select name="select2" onChange="document.select_1_and_2.submit()">
                <option value="--none--" selected>--please choose--
                <option value="fifth">another option
                <option value="sixth">and yet another option
        </select>
</form>
EOT
---------------------------------------------------------------------------

You can find the complete little test script in
<http://www.villa-chaos.de/test/autoload>.

My reference was "SELFHTML" -- an online HTML (and more) reference.
Unfortunately for most of you (I suppose) it is not available in
English... <http://selfhtml.teamone.de/>.

Wolfgang



More information about the Programming mailing list