Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

complex checkbox group

by Anonymous Monk
on Jul 20, 2004 at 21:03 UTC ( #376089=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, From within a perl cgi script, I call another script which prints date(in number of seconds since epoch), filename, day of the week. As such:
sdaf 1089176400 3 fgas 1089262800 4 ... 5y7d 1089349200 5
The date will be my tage, and I would like to have all of the monday's under one column, all the tuesdays under another, etc.

Additionally, I'd like to be able to just select mondays (or tuesdays, etc), as well as a select all button, that would select all the files.

Since you guys are about the smartest people I've ever met, and I am a descent sized green horn, I'd love a 'dumbed down' answer, but I may have asked too much already. thank you

Comment on complex checkbox group
Download Code
Re: complex checkbox group
by hbo (Monk) on Jul 20, 2004 at 23:58 UTC
    You need Date::Calc from CPAN:
    #!/usr/bin/perl use Date::Calc qw( Time_to_Date Day_of_Week ); my @weekday=( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ); my ($y,$mo,$d,$h,$m,$s)=Time_to_Date(time); my $dow = Day_of_Week($y,$mo,$d); print "Today is $weekday[$dow]\n";
      really I'm asking more about the checkboxes and how to break them into sub-check box groups ;-)
        Below is code I use for checkboxgroups. The code offered by hbo can still be used as it provides the necessary array of @weekday which you can use in my code below. Additionally if you wanted to just select a specific day set @selected to [$weekday[$num]] at the beginning and remove the where $num would represent the day of the week. I hope this code serves as a guide to help you to your own solution, unfortunately I'm at work at the moment and can't dedicate the time to writing the exact code for you. This should be pretty close I think without testing.
        ## whatever @selected is set to at the beginning ## is how your checkboxgroup will appear on loading ## Choose between one of these two lines #my @selected = @weekday; ##--> to select all #my @selected = ($weekday[#a number]); ##--> to select one foreach my $selected_day (@weekday) { my $checkbuttongroup = $rF->CheckbuttonGroup ( -list => [ $selected_day ], -orientation => 'vertical', -variable => \@selected, -font => 'bold', )->pack(-anchor => 'nw', -side => 'top', ); }
        Update: I should add that when you run the program whatever boxes you check is what @selected will contain. Eg. Monday, Wednesday etc. You can check it by using a "print $_ for @selected" on a button callback.

        Opps Update: Sorry this is how to do it in TK. I didn't see that you wanted it for CGI. If you ever get around to TK this is how its done. :-) <grinning>

        Dean
        The Funkster of Mirth
        Programming these days takes more than a lone avenger with a compiler. - sam
        RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://376089]
Approved by ysth
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2014-07-31 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (253 votes), past polls