![]() |
this is why I don't like CGI.pm
I created a checkbox with $cgi->checkbox() . It showed up fine, I can
label it, etc. But it WILL NOT CHECK on instantiation. I tried - checked => 1, -checked => "checked", -selected => "1", -selected => 1, -on => 1, etc etc. Oddly, if I change the NAME of the box, *sometimes* it checks. If I add an X to the front it will check, if I add a 2 to the end, it won't. Although this isn't repeatable. Mozilla current rev, Perl 5.8.8 Its definitely NOT a Mozilla issue- the page source is missing the checked="checked" This is why adding a CGI;pm layer is nightmarish. It's ever so much easier to just PRINT the HTML. I even asked my officemate to look at the code, and like me, he just scratched his head and walked off muttering about WHY DO WE HAVE TO USE CGI.PM ?? I hosed around with this problem like 3 hours, eventually gave up, and wrote my own check. I generate the checkbox line with cgi.pm, then perform a: s/( value)/ checked="checked"$1/ Its wacked that I had to do this... Thanks, CGI.pm like had an extra 4 hours to waste this week! |
Re: this is why I don't like CGI.pm
Mr P wrote:
> I created a checkbox with $cgi->checkbox() . It showed up fine, I can > label it, etc. But it WILL NOT CHECK on instantiation. I tried - > checked => 1, -checked => "checked", -selected => "1", -selected => 1, > -on => 1, etc etc. > > Oddly, if I change the NAME of the box, *sometimes* it checks. If I > add an X to the front it will check, if I add a 2 to the end, it > won't. Although this isn't repeatable. > > Mozilla current rev, Perl 5.8.8 > > Its definitely NOT a Mozilla issue- the page source is missing the > checked="checked" > This is why adding a CGI;pm layer is nightmarish. It's ever so much > easier to just PRINT the HTML. > > I even asked my officemate to look at the code, and like me, he just > scratched his head and walked off muttering about WHY DO WE HAVE TO > USE CGI.PM ?? > > I hosed around with this problem like 3 hours, eventually gave up, > and wrote my own check. I generate the checkbox line with cgi.pm, then > perform a: > > s/( value)/ checked="checked"$1/ > > Its wacked that I had to do this... > > > Thanks, CGI.pm like had an extra 4 hours to waste this week! > The example in the manual works right out of the box: print checkbox(-name=>'checkbox_name', -checked=>1, -value=>'ON', -label=>'CLICK ME'); your error maybe elsewhere in your code... -- Take care, Jonathan ------------------- LITTLE WORKS STUDIO http://www.LittleWorksStudio.com |
Re: this is why I don't like CGI.pm
In article <82eaa1bc-7136-49cd-b2b6-38c75c658e9e@s9g2000yql.googlegroups.com>,
Mr P <misterperl@gmail.com> wrote: >I created a checkbox with $cgi->checkbox() . It showed up fine, I can >label it, etc. But it WILL NOT CHECK on instantiation. I tried - >checked => 1, -checked => "checked", -selected => "1", -selected => 1, >-on => 1, etc etc. > >Oddly, if I change the NAME of the box, *sometimes* it checks. If I >add an X to the front it will check, if I add a 2 to the end, it >won't. Although this isn't repeatable. The same thing happened to me. I eventually figured out that if you use the same object to parse an HTTP request and write an HTML form, it assumes that fields with the same name in both are supposed to be linked, and copies the values from the request into the form, ignoring the values you told it to put there. I hated this feature too. Too much spooky behind-the-scenes action based on a completely unwarranted assumption. -- Alan Curry |
Re: this is why I don't like CGI.pm
Mr P <misterperl@gmail.com> wrote:
> I created a checkbox with $cgi->checkbox() . It showed up fine, I can > label it, etc. But it WILL NOT CHECK on instantiation. I tried - > checked => 1, -checked => "checked", -selected => "1", -selected => 1, > -on => 1, etc etc. You are probably getting tripped up by "sticky fields". They make good sense once you get around to reading that part of the documentation. It also tells you how to override them. > Thanks, CGI.pm like had an extra 4 hours to waste this week! I too often find that 4 hours of randomly flailing about and swearing will often save me from 20 minutes of reading the documentation. Xho -- -------------------- http://NewsReader.Com/ -------------------- The costs of publication of this article were defrayed in part by the payment of page charges. This article must therefore be hereby marked advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate this fact. |
Re: this is why I don't like CGI.pm
>>>>> "Alan" == Alan Curry <pacman@kosh.dhis.org> writes:
Alan> The same thing happened to me. I eventually figured out that if Alan> you use the same object to parse an HTTP request and write an HTML Alan> form, it assumes that fields with the same name in both are Alan> supposed to be linked, and copies the values from the request into Alan> the form, ignoring the values you told it to put there. This is called "sticky fields". It's (a) documented, (b) useful *most* of the time, and (c) possible to disable. Alan> I hated this feature too. Too much spooky behind-the-scenes action Alan> based on a completely unwarranted assumption. No, the assumption makes sense for the early CGI-only web. And changing it now would break too many things needlessly. print "Just another Perl hacker,"; # the original -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion |
Re: this is why I don't like CGI.pm
On 2011-10-05, xhoster@gmail.com <xhoster@gmail.com> wrote:
> > I too often find that 4 hours of randomly flailing about and swearing will > often save me from 20 minutes of reading the documentation. Xho's law? It catches me too many times, "That didn't work, oh, it must be .... nope, how about ..." say bye-bye to time. Justin. -- Justin C, by the sea. |
| All times are GMT. The time now is 01:43 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.