[prog] perl woes...
Patricia Fraser
trish at thefrasers.org
Mon Jun 2 19:52:21 EST 2003
Hi Wolfgang,
> > Second, as Jacinta said, HTML::Template simply doesn't work this
> > way. I can't seem to work out a way to use a here-document to
> > populate a drop-down list from a database table of unknown size
> > [...]
>
> Anyway, you're not bound to here-documents, are you? You could print
> out the forms by your (server-side) CGI script (other elements
> disabled, or not shown at all), let the user make the first two
> choices, and then after you know of the user's choices, do the
> following database requests and print out the rest of the form
> accordingly. The only client-side thing is that auto-submitting after
> changing the 2nd selection (or, any of the two, just as you like).
>
> Or did I misunderstand anything? Probably I don't know enough about
> HTML::Template (yet)...
No, it's not you - it's my dreadful explanation, sorry. I hope this is
better!
I found that here-documents (the HTML encapsulated in the perl code)
will allow a page refresh, but I can't use them to construct a
drop-down list using OPTION SELECT with an unknown number of OPTIONs;
in my case, I want to construct a drop-down list made up of the values
retrieved from a MySQL table. I know the values are there, I just don't
know how many of them there will be.
So, I use HTML::Template, which gives me two extras: one is the ability
to separate the perl code from the HTML and use a couple of special
variables to push data from one to the other, and the other is some
extra HTML tags for use in the HTML file so that I can construct a
drop-down list with exactly the kind of any-length loop that I need for
my drop-down list.
It works beautifully - but once the cgi script has been called, and the
HTML file has been served, I can't "go back". I can't use the looping
construct in a self-referential way using something like <form
action=original_script.cgi> to reload the page, because it simply
reloads the original form.
I think that maybe the only way to do populate a second (or third)
drop-down list with variable values, based on the choice made in the
first, particularly when the values and their number is unknown, is to
swap interminably between perl and javascript and (maybe) use a
here-document, and by gum I think it would be inelegant!
So I'm avoiding it!
Cheers,
--
Trish Fraser, Sunbury, Australia
Linux user #283226 counter.li.org
cassiopeia up 27 days and counting
kernel 2.4.18-6mdk
More information about the Programming
mailing list