G'day all... I'm curious about using HTML::Template to pre-fill in form field values.
What I'm currently using is this method <input name="my_input_box"<TMPL_IF NAME="my_input_box_value"> value="<TMPL_VAR NAME="my_input_box_value">"</TMPL_IF>> This works great for filling in text boxes. However, how can this be done for select boxes (drop-down lists)? Currently I've got a select box that looks like this: ---CUT--- <select name="my_select"> <TMPL_LOOP NAME="my_select_loop"> <option value="<TMPL_VAR NAME="id">"><TMPL_VAR NAME="description"></option> </TMPL_LOOP> </select> ---CUT--- I can't see how HTML::Template would cope with this in an automagic way. (???) I'm guessing, I could use ecma-script/j-script/javascript in the HTML with variables set to HTML::Template variables. Or something like the following: In Template: ---CUT--- <select name="my_select"> <TMPL_LOOP NAME="my_select_loop"> <option value="<TMPL_VAR NAME="id">"<TMPL_IF NAME="selected"> selected</TMPL_IF>><TMPL_VAR NAME="description"></option> </TMPL_LOOP> </select> ---CUT--- In code: ---CUT--- for $item (@$my_select_loop) { $item->{selected} = 1 if $item->{id} eq $cgi->param("id"); } [...] $template->param("my_select_loop" => $my_select_loop); print $cgi->header, $template->output; ---CUT--- Is there a simpler way, or am I just asking too much and should stop whinging and continue coding? :) TIA! Regards, Michael S. E. Kraus B. Info. Tech. (CQU), Dip. Business (Computing) Software Developer Wild Technology Pty Ltd _______________________________ ABN 98 091 470 692 Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017, Australia Telephone 1300-13-9453 | Facsimile 1300-88-9453 http://www.wildtechnology.net The information contained in this email message and any attachments may be confidential information and may also be the subject of client legal - legal professional privilege. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. This email and any attachments are also subject to copyright. No part of them may be reproduced, adapted or transmitted without the written permission of the copyright owner. If you have received this email in error, please immediately advise the sender by return email and delete the message from your system. -------------------------------------------------------------------------------- Wild Technology Pty Ltd , ABN 98 091 470 692 Sales - Ground Floor, 265/8 Lachlan Street, Waterloo NSW 2017 Admin - Level 4 Tiara, 306/9 Crystal Street, Waterloo NSW 2017 Telephone 1300-13-9453 | Facsimile 1300-88-9453 http://www.wildtechnology.net DISCLAIMER & CONFIDENTIALITY NOTICE: The information contained in this email message and any attachments may be confidential information and may also be the subject of client legal - legal professional privilege. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. This email and any attachments are also subject to copyright. No part of them may be reproduced, adapted or transmitted without the written permission of the copyright owner. If you have received this email in error, please immediately advise the sender by return email and delete the message from your system. ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users