Jason, thanks. The way you do the push helped me. I was putting the values into a temporary hash and then assigning the hash as a reference. I wanted to do it more directly like you did, but didn't know the semantics.
Regarding this: > $selected = 1 if i_want_this_option_selected( $option ); and > <TMPL_LOOP NAME=OCCUPATION_LOOP> > <option value="<TMPL_VAR NAME=VAL>" <TMPL_IF > NAME="SELECTED">SELECTED</TMPL_IF>><TMPL_VAR NAME=TEXT></option> > </TMPL_LOOP> Do you think this is more efficient, or is it more efficient to do as Puneet suggested: > $selected = ' selected' if i_want_this_option_selected( $option ); and > <TMPL_LOOP NAME=OCCUPATION_LOOP> > <option value="<TMPL_VAR NAME=VAL>"<TMPL_VAR NAME=SELECTED>><TMPL_VAR NAME=TEXT></option> > </TMPL_LOOP> It seems to me the latter would be more efficient? If I am already testing my criteria for selected, then I don't have to do an "if" again in the HTML. In other words, is it more efficient to resolve the variable contents, or to test variable? Mark ----- Original Message ----- From: "Jason Purdy" <[EMAIL PROTECTED]> To: "Mark Fuller" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, May 03, 2004 2:36 PM Subject: Re: [htmltmpl] Select/option How to set "selected"? > Hi Mark, > > How are you determining which option to pre-select? It might be better > to use HTML::FillInForm. > > Other than that, here's what you would do if you want to re-invent the > wheel: > > ### In your programming code ### > my $template = HTML::Template->new( 'filename' => 'file.TMPL' ); > my $occloop_ar = []; # occupation loop array ref. > while ( my ( $option, $value ) = $sth->fetchrow_array ) { > my $selected = 0; > $selected = 1 if i_want_this_option_selected( $option ); > push @$array_ref, { > 'VAL' => $option, > 'TEXT' => $value, > 'SELECTED' => $selected, > }; > } > $template->param( 'OCCUPATION_LOOP' => $occloop_ar ); > > ### Then in your template code ### > Occupation: <select name="occupation"> > <TMPL_LOOP NAME=OCCUPATION_LOOP> > <option value="<TMPL_VAR NAME=VAL>" <TMPL_IF > NAME="SELECTED">SELECTED</TMPL_IF>><TMPL_VAR NAME=TEXT></option> > </TMPL_LOOP> > > Cheers, > > Jason > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Html-template-users mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/html-template-users ------------------------------------------------------- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users