[Zope] Javascript onclick event and DTML
robert
robert@redcor.ch
Tue, 15 Oct 2002 19:03:59 +0200
Before I answer your question I would like to stress two things:
- Zope runs on the server (an knows nothing of the client)
- Javascript runs on the client (and knows nothing of the server)
Seeing that one understands imeidiately, that Javascript *can not
directly* access the session variables.
However there are a couple of different ways to look for a solution:
One of them I use:
- you dynamicaly generate Javascript you include in your html page. This
you do best with a pythonscript that returns the javascript.
This output you include in your page:
Example (untested):
pythonscript (called example):
var1 = getattr(context, "var1")
var2 = getattr(context, "var2")
result = """
var var1=%s;
var var2=%s;
""" % (var1, var2)
return result
ZPT using this code:
<html>
<script tal:content="example"></script>
<head>
<body>
shom somethng
</body>
Robert
AM wrote:
> Hi,
> If I had a link in which if the onclick event happened I wanted to set
> a couple of session vars how would I go about doing it??
>
> I couldnt really find anything that talks about that. Can it even be
> done??
>
> TIA
> AM
>