rsennat has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,
I have an hash of arrays which needs to be put into an HTML Template. So that hash of arrays may contain text value or selection box or drop down box.

I could do it but its really very complex. For each and every selection box, I need to create a TMPL VAR and display the values.

Is there a simpler way to do this??

Thanks.

Replies are listed 'Best First'.
Re: display hash in an html template
by Kanji (Parson) on Nov 03, 2005 at 15:29 UTC

    You may want to consult the FAQ section of HTML::Template's POD. Specifically...

    Q: What's the best way to create a <select> form element using HTML::Template?

        --k.


Re: display hash in an html template
by nedals (Deacon) on Nov 04, 2005 at 02:09 UTC
    Or something like this....
    my $ary_ref = [ { value=>1, text=>'val1'}, { value=>2, text=>'val2'}, ]; .. $template->param( select = $ary_ref, ... ); ### .tmpl <select> <TMPL_LOOP NAME=select> <option value="<TMPL_VAR NAME=value>"><TMPL_VAR NAME=text></TMPL_LOOP> </select>
A reply falls below the community's threshold of quality. You may see it by logging in.