JsRender - allowCode from Stack Overflow

http://stackoverflow.com/questions/10019578/define-a-variable-inside-a-jsrender-template

HTML

<script src="http://borismoore.github.com/jsrender/jsrender.js"></script>
<script id="movieTemplate" type="text/x-jsrender">
    <div>
        {{:#index+1}}: {{* totalx=name}} <b>{{>name}}</b> ({{>releaseYear}})
    </div>
</script>

<div id="movieList"></div>
<br />
<form>
<input type="button" value="alert_total" name="b1" id="b1" onclick="abcfx()" />
</form>

CSS

body { padding: 10px; font-family: Verdana; font-size: small }
h4 { font-size: inherit`; font-variant: small-caps; }
.height { width: 100%; margin-bottom:10px; float: left; clear: both; }
.bottom { height:400px; width: 100%; margin-bottom:10px; float: left; clear: both; }
body > button { float: left; clear: right; margin: 3px }
.subhead { margin: 3px 0 5px 0; font-weight:bolder; color:#116; font-family:Arial; font-size:10pt }
a { color: #55b; }
pre { font-size:10pt; font-weight:bold; }
.inset { padding-left: 18px; }
.box { border: 1px solid #777; padding: 5px; margin: 5px 0 30px; }
.box div { margin: 3px 0 10px 0;  }
.box .label { margin: 0; padding: 10px 0 0 0; font-style:italic; color: #55b; }
.box.label { font-style:italic; color: #55b; }
.desc { font-style:italic; margin: 0 0 15px; color:#116; }
pre { border-left: 3px solid #aaa; padding:10px; margin-bottom: 30px; }
.indexitems { list-style-type:none; padding-left:10px; margin: 0 0 20px;}
h3 { margin-bottom: 10px; font-size: 11pt;}

JavaScript

var movies = [
    {
    name: "The Red Violin",
    releaseYear: "1998"},
{
    name: "Eyes Wide Shut",
    releaseYear: "1999"},
{
    name: "The Inheritance",
    releaseYear: "1976"}
];
var totalx="no name";
// Render the template with the movies data and insert
// the rendered HTML under the "movieList" element
$("#movieList").html(
    $("#movieTemplate").render(movies));


function abcfx()
    {
alert(totalx);
}