CGI.pm and scrolling list box code error

CGI.pm and scrolling list box code error

am 31.05.2011 02:48:44 von John M Rathbun MD

--------------020805030008080906060702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Hello, World!

I'm an amateur programmer trying to convert some of my old BASIC=20
programs to run in a browser so people don't have to download and=20
install software. I'm having a problem with my current project because=20
CGI.pm is generating some funny code when I try to evoke a scrolling=20
list box.

Here's the relevant evocation:

print scrolling_list(-name =3D> 'choose',-values=3D>@terms,-size=3D>2=
54);

The HTML code output should look something like this:



What I'm actually getting follows:



This produces a list box with only one term visible. Am I doing=20
something wrong with CGI.pm or is there a glitch in it?

Thanks!

John M Rathbun MD
Asheville, NC



--------------020805030008080906060702--

Re: CGI.pm and scrolling list box code error

am 31.05.2011 05:21:51 von Uri Guttman

>>>>> "JMRM" == John M Rathbun MD writes:

JMRM> I'm an amateur programmer trying to convert some of my old BASIC
JMRM> programs to run in a browser so people don't have to download and
JMRM> install software. I'm having a problem with my current project because
JMRM> CGI.pm is generating some funny code when I try to evoke a scrolling
JMRM> list box.

JMRM> Here's the relevant evocation:

JMRM> print scrolling_list(-name => 'choose',-values=>@terms,-size=>254);

when i run this one liner it looks ok:

perl -MCGI=scrolling_list -le 'print scrolling_list( -name => 'z',-values=>[1,2,3],-size=>3)'



try to show an example with shorter data that has the same error. i also
ran the same one liner with 1..254 for the data and it seems to work as
well. i would then suspect you have some other problem in your code that
we can see. try to created a complete but short program that shows this
problem. in doing so you may even find the bug. i doubt it is in CGI.pm
as that module has been around forever and is considered very solid.

also you can easily generate that html by yourself with a simple loop or
a templater. if you can get cgi.pm to work, do that yourself.

also note that the html i saw generated is somewhat different than what
you want. it has both values and labels (which are the same here)
whereas yours only shows the labels and isn't proper html anymore.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: CGI.pm and scrolling list box code error

am 31.05.2011 05:55:42 von Michael Greb

On Mon, May 30, 2011 at 08:48:44PM -0400, John M Rathbun MD wrote:
> print scrolling_list(-name => 'choose',-values=>@terms,-size=>254);

scrolling_list wants a reference for the value list:
print scrolling_list(-name => 'choose',-values=>\@terms,-size=>254);

This should do what you want, when you use '@terms' the array gets
expanded to the list of items in the array, the backslash causes a
reference to the array to be passed instead. The relevant
documentation is perlref
.


--
Michael
michael@thegrebs.com
M: +1-562-MIKEGRB

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: CGI.pm and scrolling list box code error

am 31.05.2011 08:43:57 von Shlomi Fish

Hi John,

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, so
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:
>
>
>

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
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 .

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: CGI.pm and scrolling list box code error

am 31.05.2011 10:15:36 von rvtol+usenet

On 2011-05-31 02:48, John M Rathbun MD wrote:

> I'm an [...] trying to convert some of my old BASIC
> programs to run in a browser

Use JavaScript?

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/