[Zope] Re: TAL and Javascript
Rushabh Mehta
rmehta at gmail.com
Fri Jul 1 07:21:16 EDT 2005
Rob,
I was recently working on a similar problem.
You will need to use the xmlhttprequest function in Javascript do all the
work. And its quite easy once you get the hang of it. Heres a good tutorial
to get started:
http://developer.apple.com/internet/webcontent/xmlhttpreq.html
For your problem, if your required server result is a simple list, let a
zope script generate a tab-delimited list and you can retrive it using the
request.responseText (see the xmlhttprequest) and skip working with the
XMLDOM, which can by quite annoying.
Rushabh
----------------------------
Message: 8
Date: Wed, 29 Jun 2005 12:20:17 -0700 (PDT)
From: Rob Boyd <boydrobh at yahoo.com>
Subject: [Zope] TAL and Javascript
To: zope at zope.org
Message-ID: <20050629192017.66907.qmail at web42005.mail.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1
Thanks to all the responders. It gave me some ideas, but alas no luck.
To clarify, I am not trying to do everything in one request. Request
one generates the page, a user event (selecting an option from a form)
fires another request via javascript.
like:
<script tal:content="python:'function getFormats() {
var widget = document.getElementById('orgs');
var chosen_org = widget.options[widget.selectedIndex].value;
var formats = %s;
// build selection 2 options from formats
' % here.getDataFormats(chosen_org)" />
And then a user event (onChange) calls getFormats.
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.
I thought about AJAX (no experience), but given time constraints, looks
like I'll have to load everything on the page and go from there.
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20050701/69c94466/attachment.htm
More information about the Zope
mailing list