[Zope] Zope and Javascript
Mark Gibson
mark at kaivo.com
Wed Apr 14 18:52:46 EDT 2004
Passin, Tom wrote:
>>Behalf Of Asad Habib
>>
>>Does anyone know of any resources that describe the use of
>>Javascript within Zope? In particular, I am trying to call a
>>Javascript function using the onChange event handler that is
>>tied to a HTML select element. I need this Javascript
>>function to perform an SQL query and then have it populate
>>another HTML select element with the result set. Is this
>>possible within Zope considering that queries are performed
>>by Z SQL methods and possible other factors that I am unaware
>>of? Any help would be greatly appreciated. Thanks.
>
>
> A javascript function executed within a web page cannot influence
> anything that Zope does, because by the time that the javascript
> executes in the browser, Zope has alread finished producing the page.
> The javascript action is local to the browser.
>
> How you do it is to have your onChange handler submit a form to Zope.
> That form should invoke a document, methods, etc., on Zope that will
> construct the response you want (including any database access), and
> return it to the browser.
Another thing you can do is generate the javascript dynamically with a
python script. You'd have to do all possible queries before
displaying the form, and from that create the necessary javascript.
This would be too inefficient for a large set of data, but might be
workable for a small set. Actually, Tom's solution sounds better for
this particular problem.
Mark
More information about the Zope
mailing list