Sure, NP.
What I have got so far (I apologize if the indentation doesn't come out right):
<snipp>
...
my $cds = table caption ('CD Collection for user ' . $username),
Tr (th ([qw(Remove? Artist Album CD_vote ArtistCD_vote)])),
map { Tr (
td ([$r_user_collection->{$_}{'cd_artist'}]),
td ([$r_user_collection->{$_}{'cd_title'}]),
),
} keys %{ $r_user_collection };
$MAIN_CONTENT .= "<br>" . $cds . "<br>";
...
<schnapp-ety-schnapp>
To explain, I want to create a table (of some hundreds of rows), with 5 columns (as in the 'th' table caption).
The columns need to have the following format:
1. Checkbox
2. Text (static)
3. Text (static)
4. Combobox (values 0-6)
5. Combobox (values 0-6)
The idea is to let a user administer his / hers cd-collection, by removing and "rank" the cds.
This is just the HTML-part of a larger project, unfortunately I hate HTML with passion, so I've never bothered to learn any, and now I'm suffering the consequences.
Oh, and this is a hobby-project btw, not work-related. All I've got left is to fix the web-interface, and register a domain for the "thingy". | [reply] [d/l] |
I suggest you look at HTML::Template. The philosophy of HTML::Template is that people who are good at HTML should do HTML, and people who are good at Perl should do Perl.
With HTML::Template, you can ask a friend or a proffesional to design the HTML part for you, and then simply fill in the missing values from Perl.
The template would look somewhat like this:
<table>
<tr><th>Remove</th><th>Artist</th>.....</tr>
<TMPL_LOOP name="cd_table">
<tr>
<td><input type="checkbox" name="delete<TMPL_VAR name="__counter__">
+"</td>
<td><TMPL_VAR name="artist"></td>
<td><TMPL_VAR name="album"></td>
<td><TMPL_VAR type=select name="combo1_<TMPL_VAR name="__counter__">
+">......</td>
..... # you get the idea
</TMPL_LOOP>
</table>
The Perl code is fairly simple: to set a TMPL_VAR you assign a value to it with $template->param(name=>value). To assign all the values to the rows of a TMPL_LOOP, you assign it a reference to an array of hashes, where each hash represents one row of the table, and the hashes contain the (variable name, variable value) pairs.
Note the __counter__ references above: they are meant to give each checkbox and each combobox a name associated with the row number in which it appears: that is the only way to know which checkbox or combobox the user has selected.
Hope this helps... | [reply] [d/l] |
Thanks a bunch, I'll start exploring that module then.
<rant>
It's so hard sometimes to find the right libraries / modules / add-ons to use. Bah!
</rant>
Just to be clear though, I mean for a user to be able to submit all / some rows in one operation - I guess this is the part that confused me with FormBuilder.
Anyway, I'll get hacking, and thanks again.
| [reply] |