"be consistent" | |
PerlMonks |
Re: Checkbox Query Revisitedby dingus (Friar) |
on Nov 21, 2002 at 11:34 UTC ( [id://214742]=note: print w/replies, xml ) | Need Help?? |
A bit more info might help... However here are some comments on what I see In general a cgi script has 3 separate phases. You need to debug each and they can be developed sort of separately. Phase 1 is the form layout - in other words the request screen where you ask the user to enter what he is looking for. This can be completely separate script (or even static HTML) or it can be a subroutine in the same script as phases 2 and 3. This is where you create forms, add checkboxes etc etc. and if you don't have a phase 1 then you can rarely do anything useful. Phase 2 is validating and processing the input received from the user, this includes cookies, extended path info and the query_string as well as any POSTed parameters. Phase 2 means making sure that you have got sane defaults, that the defaults get replaced only with valid alternatives and that any invalid alternatives get flagged as errors. Phase 3 then takes the output of phase 2 and runs whatever work you want to do on it and prints the results nicely for the user. During development it is quite easy to create a dummy phase 3 only script which prints results based on input you set in the script. When you say you get blank screens and have problems with checkboxes it is unclear whether you are referin to phase 1, phase 2 or phase 3. A blank screen in Phase 1 implies that you are not correctly doing your A blank screen for the results may be because of a processing/validating error in phase 2. i.e. checboxes are not beong recognised as being set or it could be a bug in your phase 3 code that results in no DB hits no matter what happens. If you make a debug version of the script that prints the output of phase 2 before entering phase 3 you can see which one is your problem (hint Data::Dumper and s/</</g are useful things for debugging) Finally I have noticed that if you have a checkbox parameter at phase 2 then CGI.pm returns 'on' if the checkbox is set but the parameter is completely omitted if the checkbox is clear. Thus you may need to have some defaul "off" lines that get replaced if a parameter exists and is set to 'on'. Dingus Enter any 47-digit prime number to continue.
In Section
Seekers of Perl Wisdom
|
|