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><input class=3D"radio= " type=3D"radio" name=3D"recipe_type" value=3D&quo= t;Warmup" [% 'checked=3D"1"' IF 15 && 16 %]/= >Warmup<br><br></span></span></div><span class=3D""><span>incorrectly (I= think) turns into <br></span></span><pre id=3D"line1"><span><<span clas= s=3D"">input</span> <span class=3D"">class</span>=3D"<a class=3D"">rad= io</a>" <span class=3D"">type</span>=3D"<a class=3D"">radio</a>&q= uot; <span class=3D"">name</span>=3D"<a class=3D"">recipe_type</a>&quo= t; <span class=3D"">value</span>=3D"<a class=3D"">Warmup</a>" <sp= an class=3D"">checked</span>=3D"<a class=3D"">1</a>"<span>/</span= >></span><span>Warmup</span></pre>15 =3D 0000 1111<br>16 =3D 0001 0000<b= r><br></div>last time I checked, 15 & 16 =3D 0 <br><br>Adding parenthes= is didn't help either: <span class=3D""><span>[% 'checked=3D"1= "' IF (15 && 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"><<a href=3D"mailto:[email protected]" target=3D"_blank">= [email protected]</a>></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 <<a href=3D"mailto:[email protected]">wpmccormick@gma= il.com</a>> wrote:<br> <br> > I'm trying to find a slick way to make my radio buttons checked. D= oing something like ...<br> ><br> > [% IF flags && 16 %]<br> >=C2=A0 =C2=A0<input class=3D"radio" type=3D"radio&quo= t; name=3D"recipe_type" value=3D"Warmup" checked=3D&quo= t;1" />Warmup<br> > [% ELSE %]<br> >=C2=A0 =C2=A0<input class=3D"radio" type=3D"radio&quo= t; name=3D"recipe_type" value=3D"Warmup" />Warmup<br= > > [% END %]<br> ><br> > ... just seems wrong.<br> ><br> > Suggestions?<br> <br> </div></div>This is my preferred way of doing it. It doesn'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't require the END.<br> <br> =C2=A0 <input class=3D"radio" type=3D"radio" name=3D= "recipe_type" value=3D"Warmup"[% ' checked=3D"= 1"' IF flags && 16 %] />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==--