On 08/06/2010 07:23, dark0s wrote:
> I have two radio buttons and two template file in '..../templates/lib'.
> I want add to html code first template if I choice first radio button and
> second if I choice second radio button.
>
> Can tt2 manage simple javascript event like onclick?
Not by itself, no. You'll need something like jQuery for that. You
could do something like this:
First define the content in two hidden divs.
<div style="display:none">
<div id="one">
[% PROCESS template_one %]
</div>
<div id="two">
[% PROCESS template_two %]
</div>
</div>
Then your form and a div where you want the HTML displayed.
<form>
<input type="radio" name="item" value="one" /> One
<input type="radio" name="item" value="two" /> Two
</form>
<div id="output"></div>
Then use jQuery to bind a click event on each radio button that
copies the content from the relevant source div into the output
div.
<script type="text/javascript">
$(document).ready(
function() {
$('form input[type="radio"]').click(
function() {
$('#output').html(
$('#' + $(this).val()).clone()
);
}
);
}
);
</script>
Hopefully that gives you something to get started with.
More info from the jquery site: http://jquery.com/
Cheers
A
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates