SerZKO has asked for the wisdom of the Perl Monks concerning the following question:
Halo Monks, After I got some help here I've continued to work on my script which generates a HTML table by using only CGI.pm. There are at least 1M reasons why I didn't (couldn't) use HTML::Table or some other module for this purpose, so here I am now. I have a following subroutine in my script
which generates a HTML table from a csv file containing some data where user can change some data and save it back to a file by clicking on "Spara" key. From "CGI programming with Perl" book I could see that when using checkboxes you don't get neither key nor value if checkbox is unchecked. Then I thought it might be a good point to use radio buttons instead. And when I add those lines of code, then I was able to click only one radio button per column and not per row as I expected (as all td's are mapped within Tr) ?!!? What am I missing here ?sub kundNytt { my @Head = ("Anv. ID", "F\xF6r", "Efter", "Pref", "Bef", "Nytt", "Pr", + "F\xF6r", "Kap"); my $trans = $clrNr; open (TEMP, "<$tempfil") or die "Kan inte \xF6ppna filen $tempfil"; print $qry->start_form(-action => "http://skinnmaskin/cgi-bin/kon.cgi" +); print $qry->table( { Border => 1, Cellpadding => 5, bordercolor =>"#FFFFFF" }, Tr(map { th($_) } @Head), (map { my ($Uid, $Fn, $En, $Pr, $Ank, $Ext, $Or, $Adr) = split /\|/; Tr( td(textfield('UID', $Uid, 6)), td(textfield('FNA', $Fn, 20)), td(textfield('ENA', $En, 35)), td(textfield('PRE', $Pr, 10)), td(textfield('BEF', $Ext, 16)), td(textfield('NYTT', $Ank, 5)), hidden('ADRE', $Addr), td(checkbox_group('GRU',['P', 'F', 'K', 'Ej'],'Ej')), td(checkbox_group('DOL',['Ja', 'Nej'],'Nej')), td(checkbox_group('CMG',['Ja','Nej'],'Nej')), ); } <TEMP>), ); close TEMP; print $qry->hidden('kontor', $trans); print $qry->submit('spara', 'Addera rad'); print $qry->submit('spara', 'Spara'); print $qry->end_form; }
Another question is the behaviour of the checkbox group (named GRU in my case) where I would like "Ej" box to be unchecked if any(or more) of the previous boxes are checked - could I use onCheck here and how ? Or even better, is it possible to "make" checkboxes send a name even if they don't have a value (undef) ?
And at last (but not at least), I was trying to add a row to this table by clicking button "Addera rad". My idea was to add en empty row to a file I'm reading the table from and then call subroutine again. And it works so long that "empty" csv row is created in a file. But then, when I recall this subroutine, I get only one (first) row of a file. What am I missing here ? Now, I know that involving DBI is a perfect match for this database which I get in csv format, but for different reasons I'm not able to use it.
Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with CGI script behaviour
by Anonymous Monk on Aug 01, 2012 at 13:28 UTC | |
by SerZKO (Beadle) on Aug 01, 2012 at 14:33 UTC | |
|
Re: Problems with CGI script behaviour
by Anonymous Monk on Aug 01, 2012 at 17:09 UTC | |
by Anonymous Monk on Aug 01, 2012 at 17:19 UTC | |
by SerZKO (Beadle) on Aug 01, 2012 at 18:06 UTC | |
by Anonymous Monk on Aug 02, 2012 at 09:53 UTC | |
by SerZKO (Beadle) on Aug 02, 2012 at 10:17 UTC | |
|
Re: Problems with CGI script behaviour
by aaron_baugher (Curate) on Aug 01, 2012 at 14:51 UTC | |
by SerZKO (Beadle) on Aug 01, 2012 at 15:14 UTC |