[Zope] Event handling problem

Jonathan Hobbs toolkit at magma.ca
Tue Mar 1 07:43:24 EST 2005


From: "prabuddha ray" <buddha_2001 at rediffmail.com>
>   I'm using mysql database in my zope 2.7.
> While creating a page i needed to get data in one combobox after
> selecting data from another combobox. for this i need to do "page
> reload " using something like onChange() of javascript. Javascript
> won do DTML being a server side lang. I
> How do handle such events in zope in dtml.
> plz give a solution.

Just to make sure I understand what you are trying to achieve... you want
the user to enter some selection criteria, then based on what the user
enters you display a second set of selection criteria, which the user then
chooses from.  You then take combine the user's two choices to create a
mysql query or update command.

If this is what you want, then I can think of three possible solutions (and
I am sure there are more):

Solution #1

- create an html form which presents the first set of selection options.
Have the form action send the results to a dtml method/python script
- create a dtml method/python script which parses the users first selection
and creates a new form with the second set of selection criteria.  Include
within the html form a set of 'hidden' form field elements which contain the
user's first set of selection criteria.  Have this form send the results to
a second dtml method/python script
- create a second dtml method/python script which parses the second
selection form and grabs both the user-entered selection criteria (the
second set of selection criteria) and also grabs the 'hidden' form field
elements which contain the user's selections from the first form


Solution #2

- create an html form with hidden 'div's that you can display based on the
user's first choice from the selection criteria.  This will only work if:
(i) there is a limited number of options for the second set of selection
criteria, and (ii) the second set of selection criteria is 'static'


Solution #3

- create an html form that has a javascript function that gets invoked when
the user makes a choice from the selection criteria.  This javascript
function takes the user's selection and creates a url with the user's
selection as parameters.  The javascript function then uses the url to load
a dtml method/python script into a hidden iframe in the original html form.
The dtml method/python script receives the parameters (passed thru the url),
processes them to determine the contents of the second set of selection
criteria, then creates javascript variables containing the information for
the second set of selection criteria.  These javascript variables are then
loaded into the hidden iframe and become accessible to the original
javascript function which can then create and display the second set of
selection criteria.

This solution is a bit more difficult to implement, but if you don't want to
reload the page while the user is looking it should do the trick!

hth

Jonathan






More information about the Zope mailing list