On Tuesday 31 May 2011 03:48:44 John M Rathbun MD wrote:
Hello, World!
I'm an amateur programmer trying to convert some of my old BASIC
programs to run in a browser so people don't have to download and
install software. I'm having a problem with my current project because
CGI.pm is generating some funny code when I try to evoke a scrolling
list box.
Here's the relevant evocation:
print scrolling_list(-name => 'choose',-values=>@terms,-size=>254);
The problem here is that -values accepts an array reference, not an array, soHello, World!
I'm an amateur programmer trying to convert some of my old BASIC
programs to run in a browser so people don't have to download and
install software. I'm having a problem with my current project because
CGI.pm is generating some funny code when I try to evoke a scrolling
list box.
Here's the relevant evocation:
print scrolling_list(-name => 'choose',-values=>@terms,-size=>254);
you need either:
print scrolling_list(-name => 'choose', -values => \@terms, -size => 254);
Or:
print scrolling_list(-name => 'choose', -values => [@terms], -size => 254);
See the resources in: http://perl-begin.org/topics/references/ .
The HTML code output should look something like this:
<SELECT NAME="choose" SIZE="254">
<OPTION> abreaction
<OPTION> abstract thinking
<OPTION> acalculia
.
.
.
<OPTION> word salad
<OPTION> xenophobia
<OPTION> zoophobia
</SELECT>
This is non-standards-compliant HTML code.
What I'm actually getting follows: [SNIP]
This produces a list box with only one term visible. Am I doing
something wrong with CGI.pm or is there a glitch in it?
Well, I would strongly suggest against using CGI.pm's HTML generation<SELECT NAME="choose" SIZE="254">
<OPTION> abreaction
<OPTION> abstract thinking
<OPTION> acalculia
.
.
.
<OPTION> word salad
<OPTION> xenophobia
<OPTION> zoophobia
</SELECT>
This is non-standards-compliant HTML code.
What I'm actually getting follows: [SNIP]
This produces a list box with only one term visible. Am I doing
something wrong with CGI.pm or is there a glitch in it?
routines. Instead you should use either the Template Toolkit (
http://template-toolkit.org/ ) or alternatively
http://search.cpan.org/dist/HTML-FormFu/ or something like that.
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs
NASA Uses COBOL.
Please reply to list if it's a mailing list post - http://shlom.in/reply .