Javascript onclick event and DTML
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 -- ================================================================== Aseem Mohanty Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231 ================================================================== "I saw `cout' being shifted "Hello world" times to the left and stopped right there!!" -- Steve Gonedes ==================================================================
You would cause the onclick event to call a JavaScript function that itself calls back in to Zope via HTTP to a method that sets the session vars. On Tue, 2002-10-15 at 12:32, 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
-- ================================================================== Aseem Mohanty Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231 ================================================================== "I saw `cout' being shifted "Hello world" times to the left and stopped right there!!" -- Steve Gonedes ==================================================================
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
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
participants (3)
-
AM -
Chris McDonough -
robert