[Zope] Detecting which form button is pushed?
Hung Jung Lu
hungjunglu@hotmail.com
Sun, 20 Feb 2000 07:19:30 PST
petru paler <ppetr-@coltronix.com> wrote:
><dtml-if "_.hasattr(REQUEST, 'create')">
> (user pushed create)
><dtml-elif "_.hasattr(REQUEST, 'edit')">
> (user pushed edit)
><dtml-else "_.hasattr(REQUEST, 'delete')">
> (user pushed delete)
></dtml-if>
-------------------
I usually use:
<dtml-if "REQUEST.has_key('create')">
...
<dtml-if "REQUEST.has_key('edit')">
...
<dtml-if "REQUEST.has_key('delete')">
...
</dtml-if>
-------------------
That works fine is the form does not need different
action http's. When the form needs different action
http's, it's more complicated. I don't have a good way
of doing it except by using a hidden field in combination
with a button and javascript. And Netscape is quite
primitive and unforgiving when it comes to javascripts.
<script "javascript1.1">
function submitCreate() {
document.myForm.action = 'http://.../create';
document.myForm.myActionType = 'create';
...
if (everything_is_fine) {
document.myForm.submit();
return true;
} else {
alert('problems found.');
return false;
}
}
function submitEdit() {...}
function submitDelete() {...}
</script>
<form name="myForm" method="post">
...
<input type="hidden" name="myActionType">
<input type="button" onclick="submitCreate()">
<input type="button" onclick="submitEdit()">
<input type="button" onclick="submitDelete()">
</form>
And on the server side:
<dtml-if "REQUEST.has_key('myActionType') and
REQUEST.myActionType == 'create'">
...
If anyone else has a better approach, please let
me know. Thanks.
Hung Jung
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com