<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
The issue is that the template work is done <i>server-side</i> and
the javascript is run <i>client-side</i> so you cannot send client
data to the server before it gets rendered unless you make another
server request once the data is read. (But you can put server values
into client vars.)<br>
<br>
However, you say "save the resulting string into a cookie". You can
do that in javascript or jQuery. For the latter<br>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pln">$</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="str">"cookiename"</span><span class="pun">,</span><span class="pln"> JSON</span><span class="pun">.</span><span class="pln">stringify</span><span class="pun">(</span><span class="pln">$</span><span class="pun">(</span><span class="str">"#MyData"</span><span class="pun">).</span><span class="pln">data</span><span class="pun">()));</span></code></pre>
or in pure JavaScript<br>
<br>
document.cookie=<span class="highVAL">"cookiename=whatever;
expires=Thu, 10 Sep 2015 00:00:01 UTC; path=/mypath"</span>;<br>
<br>
<br>
<div class="moz-cite-prefix">On 9/8/2015 4:13 PM, Nikos Vaggalis
wrote:<br>
</div>
<blockquote
cite="mid:CA+PXb4ZDJdpTdfCbr7LcuypAigDdS-NWtNg4C_dhHt6yOFsHbw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>More educational value out of this question than
a practical one<br>
<br>
</div>
Is it possible to interpolate a Javascript variable as
to assign it's value to a TT variable?<br>
</div>
The scenario would be that from within the materialized
template to extract value pairs from DOM elements like
sliders,select groups etc,serialize them and save the
resulting string into a cookie:<br>
</div>
<br>
<script><br>
var getvalue = $(
"#Brand").find(":selected").parent("optgroup").attr("label");<br>
jsvar = {Brand:getvalue};<br>
jsvar = JSON.strignify(jsvar);<br>
[% SET session.ttvar= jsvar ]%<br>
</script><br>
<br>
</div>
<div>Imagine going through a series of elements,capturing
the values which can be used later on as parameters to a
POST call i.e<br>
<br>
</div>
<div>{Brand:...,Price_from....,Price_to:...}<br>
<br>
</div>
since they would be saved in a cookie which would be valid
for the rest of the session, they could be reused by the
same or another route for purposes of for example
reinstating or remembering the previous state after the back
button of the browser is hit <br>
<br>
</div>
Of course, that could be done with an Ajax call but been
thinking of alternative ways <br>
<br>
</div>
So the problem here is how do you escape out of the TT context
and inject temporary Javascript context in [% SET
session.ttvar= jsvar %] ,so that jsvar gets assigned to ttvar ?
</div>
</blockquote>
<br>
<div class="moz-signature">-- <br>
John J. McDermott, CPLP<br>
Learning and Performance Consultant<br>
jjm at jkintl.com 575/737-8556<br>
Check out my <a href="http://cybersecurity.learningtree.com">
security blog posts</a><br>
Add an A for the Arts To STEM and get STEAM and a strong engine to
move forward. </div>
</body>
</html>