[htmltmpl] Problem with <select>
Brought to you by:
samtregar
From: Robert M. <rw...@uc...> - 2003-07-31 02:16:52
|
Greetings, I've been a long time fan and user of HTML::Template, but this is the first time I've tried to do this particular thing. Can someone tell me what I'm doing wrong? I've been looking at this but I think I need another pair of eyes to point out my error (probably something dumb). I've read past messages about filling in an HTML select form, coded it, and it *almost* seems to work, but its not putting the 'selected' token in there! Any help would be appreciated. [FYI: It's purpose is a question/answer confirmation for someone who forgets their password. Thus the 'pwq' below is short for 'PassWord Question', if you're wondering. There are other fields on the form, but those all work fine.] Here's my HTML (everything between <option></option> is actually on one line, just indented here for readability): <select name="pwq"> <tmpl_loop name="htmlselect"> <option value="<tmpl_var name='selectcode'>" <tmpl_if name='isSel'> selected</tmpl_if>> <tmpl_var name='selectdesc'></option> </tmpl_loop> </select> ..then my code has the fill routine like so (some more fluff removed for readability, but this is the meat of it): sub FillForm { my $tmplref = shift; # Reference to the HTML::Template my $formref = shift; # Reference to the form data hash my $useropt = $$formref{'pwq'}; # User selection ('06' for this example) Log("FillForm(useropt=$useropt)") if $debug; my %options; my @htmlselect = (); my $pwqref = getPWQhash(); # Build hash of code=>text data from a file foreach (sort keys %{$pwqref}) { my $sel = ( $_ eq $useropt ? 1 : 0 ); my %row = ('selectcode' => $_, 'selectdesc' => $$pwqref{$_}, 'isSel' => $sel); push @htmlselect, \%row; Log(" C=$_, D=$$pwqref{$_}, SEL=$sel") if $debug; } $tmplref->param('htmlselect' => \@htmlselect); } ...and in my log file (from the Log() functions above) is shows that the sixth option is being identified as the one selected (which I did), but for some reason that doesn't get translated to the HTML code: FillForm(useropt=06) C=00, D=(sometext00), SEL=0 C=01, D=(sometext01), SEL=0 C=02, D=(sometext02), SEL=0 C=03, D=(sometext03), SEL=0 C=04, D=(sometext04), SEL=0 C=05, D=(sometext05), SEL=0 C=06, D=(sometext06), SEL=1 <--- Var is set to 1 C=07, D=(sometext07), SEL=0 C=08, D=(sometext08), SEL=0 C=09, D=(sometext09), SEL=0 C=10, D=(sometext10), SEL=0 However, the result is just as if it was a blank form, with no 'selected' token in the select list. Doing a View Source just looks like: <select name="pwq"> <option value="00">(sometext00)</option> <option value="01">(sometext01)</option> <option value="02">(sometext02)</option> <option value="03">(sometext03)</option> <option value="04">(sometext04)</option> <option value="05">(sometext05)</option> <option value="06">(sometext06)</option> ('selected' should be here?!?!) <option value="07">(sometext07)</option> <option value="08">(sometext08)</option> <option value="09">(sometext09)</option> <option value="10">(sometext10)</option> </select> Thanks and first round on me for whoever helps point out my problem. :) Robert |