in reply to html::template with dynamic checkbox

First of all, you build HTML inside your script, not in the template - if you do that, there's no need for a templating system.

You have to prepare the data inside your script:

my @checkboxes = (); my $checked = 3; for (1 .. 5){ my %rowh = ( name => "desc_$_" , description => "description ($_) ", ) if ($checked == $_) { $rowh{checked} = 1; } push @checkboxes, \%rowh }

And in the template:

<TMPL_LOOP NAME=CHECKBOX_HEADER> <input type="checkbox" name="<TMPL_VAR NAME=name>" <TMPL_IF NAME=checked>checked="checked"</TMPL_IF>> <TMPL_VAR NAME=description</TMPL_VAR></input> </TMPL_LOOP>

Replies are listed 'Best First'.
Re^2: HTML::Template with dynamic checkbox
by adrive (Scribe) on Sep 12, 2007 at 09:02 UTC
    thanks moritz, you really helped me see the concept to do it!