From: "Tino Wildenhain" <tino@wildenhain.de> Subject: Re: [Zope] javascript vars in dtml
Am Freitag, den 25.02.2005, 11:41 +0000 schrieb cla:
Hi!
i would like to know if its possible to pass javascript variables to dtlm methods.
for example: <script type="text/javascript">
function general(){
var t="hello"
/* here is the problem until now within dtml the they dont recognize the t var */
<dtml-in "func(t)"> ... </dtml-in>
}
</script>
thanks
You are confused :-) JavaScript is entirely interpreted by the client - the client gets the page after the server has fully processed it.
But, in the case where you want javascript to process user entered data, or to provide additional information based on some user action, you have two options (that i can think of, there are probably more!): 1) have javascript create additional 'form' fields containing the info you want passed back to dtml/scripts (said form fields can then be processed as usual) 2) create a hidden iframe in your html page; use javascript to reload this page by building a url (with data parameters) which invokes a dtml/script routine. The dtml/script can process the parameters passed in the url and then pass whatever you want back to the client where your javascript can then interpret the response from the dtml/script. This is a nice way of communicating between the client and your zope site without the user seeing page reloads. hth Jonathan