--- In [EMAIL PROTECTED], Robert Del Huerto <[EMAIL PROTECTED]> wrote:
>I can get Zope to generate a table and form like this from an SQL
>database.  I'm stuck after that.  The form only has one 'action' so how
>would I get it to handle the right function depending on the button that
>was pushed?

The short answer is: use JavaScript.

Instead of using <input type=submit ...>, I use <input type=button ...>. I 
guess an example is better than long explanations.

  <form name=my_form method=get>
  <input type=hidden name=handling_method>
  <input type=button value="Notes" onclick="go_notes()">
  <input type=button value="Edit" onclick="go_edit()">

<script language="JavaScript1.1">
if (document.images) {

function go_notes() {
    // example of a submission without handling method
    document.my_form.action = "&dtml.url-Notes;" ;

function go_edit() {
    // example of a submission with handling method
    document.my_form.handling_method.name = "method_edit:method";
    document.my_form.action = "&dtml.url-Person;" ;

// -->

In the first case (go_notes), your submission is sent to the "Notes" folder 
inside Zope, and it's handled by the conventional index_html method.

In the second case (go_edit), your submission is sent to the "Person" folder 
and it's handled by the "method_edit" method inside the "Person" folder. The 
"method_edit:method" tag in the above code tells Zope that "method_edit" is 
a method. It's a Zope thing, and you won't find it in JavaScript books. I 
find it useful to put my methods that handle a Person inside the Person 
folder, so I can have something like


neatly lined up inside the Person folder. Another trick is, inside these 
handling methods, at the end I do a redirection, something like:

  <dtml-call "RESPONSE.redirect(MyNextPage.absolute_url() + '?person_id=%s' 
% my_person_id)">

That is, the handling methods only handle the logical part. For actually 
displaying the result, I use redirection to a displaying page.

Oh, on the &dtml.url-...; notation: if you need more complicated URLs, you 
cannot use the "&dtml.url-Object;" notation. You have to use "<dtml-var 
"MyFolder.MySubFolder.Object.absolute_url()">" notation instead.

Now you know how to make Zope work for you. :)


Hung Jung

Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to