|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Hi guys.
I am a severe rookie (newbie) in the Zope/python enviroment. I therefore need some help on calling python functions in dtml code. I typed the following in one of my pages but to no avail: <input type="text" value="<dtml-call expr="pyFeedback.doTotal('text1','text2')">" name="total:int:ignore_empty"> </td> The function as you can see is called doTotal and it basically is supposed to display the sum of 2 values in text boxes. Am I on the right track? Rookie pythoneer. ![]() |
|
#2
|
||||
|
||||
|
If you want the result of a Python expression put in place of your dtml tag, you need to use dtml-var. dtml-call evaluates an expression, but does not put the result of that expression into the rendered page.
Fixed code: Code:
<input type="text" value="<dtml-var expr="pyFeedback.doTotal('text1','text2')">" name="total:int:ignore_empty">
Ever consider using ZPT? Things are much easier to read/maintain in it. ![]() Here's the same thing in ZPT: Code:
<input type="text" tal:attributes="value python:here.pyFeedback.doTotal('text1','text2')" name="total:int:ignore_empty">
No "tags in attributes" that way! ![]()
__________________
Lucas Marshall |
|
#3
|
|||
|
|||
|
Thank you for your help Lucas. I was really stressed about that one.
Now I have another problem. I am trying to email the text on a web page. The email gets to its destination but the contents are just gibberish! Is there a way that it can be received in another format apart from .dat? How about .doc or just the page as it is (html)? I'd really appreciate your help. Mutinda. |
|
#4
|
|||
|
|||
|
I spoke too soon!
I have just tried to call the corrected function but it still has a problem. Is there a simpler way to display the total of several textboxes(with integer values) on a form in one textbox on the same form? Is it possible for the "total" textbox to have a default state where it "totals" & displays the totals as soon as the form is active? Mutinda. |
|
#5
|
||||
|
||||
|
So, you want to be able to enter a couple of numbers in a couple of text boxes and have the sum of the two display in another text box on the same form? If so, that's not a job for any server side language... it's a job for JavaScript.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > python functions in dtml |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|