[Zope] redirection from within forms with submit button

dvl dvl <dvl@wanadoo.nl>
Thu, 4 Apr 2002 21:16:11 +0200


Hello Oliver,

> Of course, the dtml-call has an effect, namely the same independent
> from where it is written. It's just that writing it into the value
> attribute of the submit button doesn't give any extra functionality,
> like e.g. doing the call when the submit button is pressed.

If I use your code
<dtml-if x>
<dtml-call "REQUEST.set('datum', _.str('1796/03/11'))">
<dtml-call "REQUEST.set('teller', 5)">
<dtml-call "RESPONSE.redirect('toondecr?datum=%s&teller=%s' % (datum,teller))">
</dtml-if>
<form method="post" action="">
<input type="submit" name="x" value="ROEPTOON&gt;&nbsp;">
</form>

in a separate method, it does exactly that: the call is performed when
and only if the submit button is pressed.

When i use it in the method 'toondecr', and click on the submit
button, I get
Error Value: global name 'datum' is not defined

What i want to do is the button equivalent of the link
<a href="<dtml-var "'toondecr?datum=%s&teller=%s' % (datum)">">Next</a>
(which works, in the method 'toondecr')

I don't know if some kind of (quasi) recursion is at hand or if datum
is not properly recognised as a DateTime string.

> Well, the code I posted does work (tested), so I'm quite sure your name
> error appears somewhere else.

Yes, i suppose so. As it is, i've spent far too much time (which is
running out for this project) on this issue and i'll revert to plain
links for the time being. That is not to say i didn't pick up some
good things from the efforts and your help for which thanks once more.


> Could you use the code I posted in your method - because it's less
> confusing IMO - and, if it doesn't work, post the whole source code.

Well i'm afraid you got better things to do, but here it is. If you feel
you'd have so see further coding, i'd gladly provide it. Thanks for
your time, cheers, Dirk

method 'toondecr'

<dtml-var standard_html_header>

<dtml-let navcaller=document_title>
<dtml-var navbar> 
</dtml-let>

<dtml-in "decrQuery(_.None, _, datum=(_.str(datum)))" size=1 start=teller>
<dtml-call "REQUEST.set('totaal', _['count-datum'])">


<table width="100%" border=0>
<tr>

<td align=left valign="top" width="100%">
<dtml-if previous-sequence>
<a href="<dtml-var "'toondecr?datum=%s&teller=1' % (datum)">"
style="text-decoration: none;"><b>   &lt;&lt;&nbsp;</b>eerste    &nbsp;&nbsp;</a>
<dtml-else>&nbsp
</dtml-if previous-sequence>
</td>

<td align=center valign="top" width="100%">
<dtml-if previous-sequence>
<dtml-call "REQUEST.set('teller', _['sequence-number'])">
<dtml-call "REQUEST.set('teller', teller-1)">
<a href="<dtml-var "'toondecr?datum=%s&teller=%s' % (datum, teller)">"
style="text-decoration: none;"><b>   &lt;</b>&nbsp;vorige    &nbsp;&nbsp;</a>
<dtml-call "REQUEST.set('teller', teller+1)">
<dtml-else>&nbsp
</dtml-if previous-sequence>
</td>


<td align=center valign="top" width="100%">
<dtml-if next-sequence>
<dtml-call "REQUEST.set('teller', _['sequence-number'])">
<dtml-call "REQUEST.set('teller', teller+1)">
<a href="<dtml-var "'toondecr?datum=%s&teller=%s' % (datum, teller)">"
style="text-decoration: none;"><IMG SRC="vooruitbutton"
ALT="vooruitbutton" WIDTH=30 HEIGHT= BORDER=0><b>   </b>&nbsp;    &nbsp;&nbsp;</a>
<dtml-call "REQUEST.set('teller', teller-1)">
<dtml-else>&nbsp
</dtml-if next-sequence>

</td>

<td align=right valign="top" width="100%">
<dtml-if next-sequence>
<a href="<dtml-var "'toondecr?datum=%s&teller=%s' % (datum, totaal)">"
style="text-decoration: none;"><b>   &gt;&gt;</b>&nbsp;laatste    &nbsp;&nbsp;</a>
<dtml-else>&nbsp
</dtml-if next-sequence>
</td>

</tr></table>


<table><tr>
<td align=right valign="top" width="100%">



<dtml-if x>
<dtml-call "REQUEST.set('datum', _.str('1796/03/11'))">
<dtml-call "REQUEST.set('teller', 5)">
<dtml-call "RESPONSE.redirect('toondecr2?datum=%s&teller=%s' % 
(datum,teller))">
</dtml-if>

<form method="post" action="">
<input type="submit" name="x" value="&gt;&nbsp;">
</form>


</td></tr></table>




<table width="100%">
<tr>
<td align=left><dtml-var directory>/<dtml-var imagenaam></td>
<td align=center>Decreet van <dtml-var datum></td>
<td>image  <dtml-var sequence-number> van <dtml-var totaal> voor deze dag</td>
<td>p. <dtml-var bladzijde></td>
</tr></table>


<table width="100%">
<tr>
<td align=center>
<img src="http://192.87.107.12/dddimages/Decreet/Web/film01/<dtml-var
imagenaam>.gif" alt="<dtml-var directory>/<dtml-var imagenaam>">
</td></tr></table>

</dtml-in>