Re: setting <input> checked

Bill McCormick <[email protected]> Fri, 5 Dec 2014 10:56:08 -0600
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CAK_+aRBgvYqsm2odpkPWtfnaVsBF5EnoiOzpiFYLN7Y-9Mt+zg@mail.gmail.com>
--===============8006365967186115732==
Content-Type: multipart/alternative; boundary=001a11391eee3edea005097af50d

--001a11391eee3edea005097af50d
Content-Type: text/plain; charset=UTF-8

okay, so now the bitwise *and *is giving me problems:

<input class="radio" type="radio" name="recipe_type" value="Warmup" [%
'checked="1"' IF 15 && 16 %]/>Warmup

incorrectly (I think) turns into

<input class="radio" type="radio" name="recipe_type" value="Warmup"
checked="1"/>Warmup

15 = 0000 1111
16 = 0001 0000

last time I checked, 15 & 16 = 0

Adding parenthesis didn't help either: [% 'checked="1"' IF (15 && 16) %]

Also, is there some way TT can interpret numbers as hexadecimal (e.g. 16 =
0x10)?

Thanks!

On Fri, Dec 5, 2014 at 9:37 AM, Simon Amor <[email protected]> wrote:

> On 5 Dec 2014, at 14:38, Bill McCormick <[email protected]> wrote:
>
> > I'm trying to find a slick way to make my radio buttons checked. Doing
> something like ...
> >
> > [% IF flags && 16 %]
> >   <input class="radio" type="radio" name="recipe_type" value="Warmup"
> checked="1" />Warmup
> > [% ELSE %]
> >   <input class="radio" type="radio" name="recipe_type" value="Warmup"
> />Warmup
> > [% END %]
> >
> > ... just seems wrong.
> >
> > Suggestions?
>
> This is my preferred way of doing it. It doesn't have as many [% %] tags
> as other options which IIRC makes it a little faster than keep swapping
> between TT and HTML, and it doesn't require the END.
>
>   <input class="radio" type="radio" name="recipe_type" value="Warmup"[% '
> checked="1"' IF flags && 16 %] />Warmup
>
> Regards
>
> Simon

--001a11391eee3edea005097af50d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><span class=3D""><span>okay, so now the bit=
wise <i>and </i>is giving me problems:<br><br>&lt;input class=3D&quot;radio=
&quot; type=3D&quot;radio&quot; name=3D&quot;recipe_type&quot; value=3D&quo=
t;Warmup&quot; [% &#39;checked=3D&quot;1&quot;&#39; IF 15 &amp;&amp; 16 %]/=
&gt;Warmup<br><br></span></span></div><span class=3D""><span>incorrectly (I=
 think) turns into <br></span></span><pre id=3D"line1"><span>&lt;<span clas=
s=3D"">input</span> <span class=3D"">class</span>=3D&quot;<a class=3D"">rad=
io</a>&quot; <span class=3D"">type</span>=3D&quot;<a class=3D"">radio</a>&q=
uot; <span class=3D"">name</span>=3D&quot;<a class=3D"">recipe_type</a>&quo=
t; <span class=3D"">value</span>=3D&quot;<a class=3D"">Warmup</a>&quot; <sp=
an class=3D"">checked</span>=3D&quot;<a class=3D"">1</a>&quot;<span>/</span=
>&gt;</span><span>Warmup</span></pre>15 =3D 0000 1111<br>16 =3D 0001 0000<b=
r><br></div>last time I checked, 15 &amp; 16 =3D 0 <br><br>Adding parenthes=
is didn&#39;t help either: <span class=3D""><span>[% &#39;checked=3D&quot;1=
&quot;&#39; IF (15 &amp;&amp; 16) %]</span></span><br><br></div>Also, is th=
ere some way TT can interpret numbers as hexadecimal (e.g. 16 =3D 0x10)? <b=
r><div><br></div><div>Thanks!<br></div><div><div><div class=3D"gmail_extra"=
><br><div class=3D"gmail_quote">On Fri, Dec 5, 2014 at 9:37 AM, Simon Amor =
<span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">=
[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa=
dding-left:1ex"><div class=3D""><div class=3D"h5">On 5 Dec 2014, at 14:38, =
Bill McCormick &lt;<a href=3D"mailto:[email protected]">wpmccormick@gma=
il.com</a>&gt; wrote:<br>
<br>
&gt; I&#39;m trying to find a slick way to make my radio buttons checked. D=
oing something like ...<br>
&gt;<br>
&gt; [% IF flags &amp;&amp; 16 %]<br>
&gt;=C2=A0 =C2=A0&lt;input class=3D&quot;radio&quot; type=3D&quot;radio&quo=
t; name=3D&quot;recipe_type&quot; value=3D&quot;Warmup&quot; checked=3D&quo=
t;1&quot; /&gt;Warmup<br>
&gt; [% ELSE %]<br>
&gt;=C2=A0 =C2=A0&lt;input class=3D&quot;radio&quot; type=3D&quot;radio&quo=
t; name=3D&quot;recipe_type&quot; value=3D&quot;Warmup&quot; /&gt;Warmup<br=
>
&gt; [% END %]<br>
&gt;<br>
&gt; ... just seems wrong.<br>
&gt;<br>
&gt; Suggestions?<br>
<br>
</div></div>This is my preferred way of doing it. It doesn&#39;t have as ma=
ny [% %] tags as other options which IIRC makes it a little faster than kee=
p swapping between TT and HTML, and it doesn&#39;t require the END.<br>
<br>
=C2=A0 &lt;input class=3D&quot;radio&quot; type=3D&quot;radio&quot; name=3D=
&quot;recipe_type&quot; value=3D&quot;Warmup&quot;[% &#39; checked=3D&quot;=
1&quot;&#39; IF flags &amp;&amp; 16 %] /&gt;Warmup<br>
<br>
Regards<br>
<span class=3D""><font color=3D"#888888"><br>
Simon</font></span></blockquote></div><br></div></div></div></div>

--001a11391eee3edea005097af50d--


--===============8006365967186115732==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

--===============8006365967186115732==--