[Zope] TAL and Javascript

Jonathan dev101 at magma.ca
Wed Jun 29 16:14:47 EDT 2005


----- Original Message ----- 
From: "Rob Boyd" <boydrobh at yahoo.com>
> Thanks to all the responders. It gave me some ideas, but alas no luck.
>
>
>
> Even with generating the script with a Python script or DTML, the
> problem remains (for me at least) to get a value from the DOM passed as
> an argument to a Python script that queries my database. If my Python
> script didn't take an argument, I'd have no problem. I could do this
> and use javascript to build the select options from the appropriate
> values. But I'd like to cut down on what the browser has to handle.
> What the user chooses in the first selection can reduce what they get
> to choose in selection two from 3000 choices to hundreds. I'd prefer to
> have the backend reduce the result set rather than having the browser
> do the work.

We do this a lot... a few key concepts to get you going:

1) You can embed dtml tags  within javascript, eg:
      hiddenframe.location.href = '<dtml-var 
baseurl>Sub_GetPresentorPage?confid=<dtml-var login_id>&SessUpd=1'

This allows you to write scripts which generate javascript code that is 
specific to the situation (when zope processes the dtml tags, the tags will 
be replaced with 'data' which then becomes part of the javascript code).


2) You can set javascript variables from dtml/scripts, eg:

    parent.presentorpage= '<dtml-var 
"temp_folder.getProperty(confid+'_CurrSlide')">'

This allows you to store zope objects/fields/etc in variables that 
javascript can then use.


3) We use hidden html frames to provide a location that javascript can 
reload in order to make 'invisible' (not really, but close enough) calls 
from the browser to the server


hth

Jonathan





More information about the Zope mailing list