I am putting together a web form using CGI::Formbuilder and Template Toolkit. All was going well until I decided to add a Javascript Calendar widget to the form.

Although the CGI::Formbuilder doc states :-

[htmlattr] => $value, [htmlattr] => $value In addition to the above tags, the field() function can take any other + valid HTML attribute
When I attempt to pass in the anchor definition including some java script ala:-
my $lot =<<EOF; href="javascript:void(0)" onclick="gfPop.fPopCalendar(document.demofor +m.dc);return false;" HIDEFOCUS><img name="popcal" align="absmiddle" s +rc="calbtn.gif" width="34" height="22" border="0" alt=""> EOF $form->field(name => 'go_live_date', a => $lot);
I end up with the following output :-
<td width="100"><input a="href=&quot;javascript:void(0)&quot; onclick +=&quot;gfPop.fPopCalendar(document.demoform.dc);return false;&quot; H +IDEFOCUS&gt;&lt;img name=&quot;popcal&quot; align=&quot;absmiddle&quo +t; src=&quot;calbtn.gif&quot; width=&quot;34&quot; height=&quot;22&qu +ot; border=&quot;0&quot; alt=&quot;&quot;&gt; " class="FormField" cols="20" name="go_live_date" type="text" /></td>
I have a feeling that i'm not quoting the string correctly - or passing it in incorrectly. Either way I'd appreciate some advice on what is the correct way to pass in random html markup of this nature from CGI::Formbuilder into Template Toolkit.

Thanks Simon


In reply to Javascript with CGI::FormBuilder and Template Toolkit by set_uk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.