[Templates] sending javascript value to TT2

Bill Ward bill@wards.net
Wed, 6 Jun 2007 01:38:27 -0700


On 6/6/07, Bill Ward <bill@wards.net> wrote:
> On 6/4/07, Josh Rosenbaum <josh@infogears.com> wrote:
> > Rajkumar Natarajan wrote:
> > > I am using Javascript to read a cookie. Now,  I want  to pass the
> > > value  to  TT2.
> > > How to pass javascript(vari)  to TT2(rate_email)  ?
> > [SNIP]
> >
> > Javascript is processed in the browser (client-side), not by TT(server-side). You should be accessing the cookie via your backend/TT without the use of javascript.
>
> The TT can place the value into a hidden field or generate a snippet
> of JavaScript code to populate a variable....one of these should do:
>
> <input type="hidden" name="something" value="[% something %]" />
> <script>var something='[% something %]';</script>

Oh sorry I read the original question backward.

Your JavaScript could modify the value of the hidden field, and then
submit it as form data.  But that has nothing to do with TT; it's
basic CGI.

Or get clever with Ajax if you like, I suppose.

--Bill.