I'm a newbie to HTML::Template, and this
is my first post to the list ....

My question has to do with radio buttons,
and any recommended ways of carrying
a checked value through successive forms.

I have my forms set up so submission errors
(a missing required field, for example) are
"carried through" ... that is, the form is regenerated,
and any fields filled out in the first submission
retain their respective values at the next iteration.

This all works fine, and I've been able to figure out
how to carry drop-down lists values along as well. Example:

Choose an item from the list:
<select name="Item">
<!--TMPL_IF NAME="Item" -->
<option selected><!--TMPL_VAR NAME=Item -->
<!--/TMPL_IF-->
<option>
<option value="1">One
<option value="2">Two
<option value="3">Three
</select>

What I'm trying to do is figure out a way to do something
similar with radio buttons .... in other words, carry a "checked"
value through to the next form generation. The wrinkle
that's causing me to scratch my head is that the field-name
value is the same for each radio button, so I *can't* do something
like:

<input type="radio" name="Color" value="Red"
<!--TMPL_IF NAME="Color" -->
 checked
<!--/TMPL_IF-->
">

<input type="radio" name="Color" value="Blue"
<!--TMPL_IF NAME="Color" -->
 checked
<!--/TMPL_IF-->
">

I'm wondering if I'm missing something simple here .....
I've got things working with a pretty cludgy looking work around:
In the programming:

        ##CH likely a better way to do this
if ($q->param('Color') eq 'Red') {
        $q->param('Red','checked')
};
if ($q->param('Color') eq 'Blue') {
        $q->param('Blue','checked')
};

And in the template:

<input type="radio" name="Color" value="Red" <!--TMPL_VAR NAME=Red -->">
<input type="radio" name="Color" value="Blue" <!--TMPL_VAR NAME=Blue -->">

But the above is really ugly, and I gotta believe
there's a better approach (that I'm too dense to recognize)

Any suggestions?

Carl
[EMAIL PROTECTED]







-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to