[Zope-dev] Using Java-Script with DTML

Monty Taylor mtaylor@goldridge.net
Fri, 30 Jun 2000 08:52:18 GMT


If you don't mind the complication, you can use the xml-rpc Java Applet 
(I can't remember where it comes from) and the Javascript hooks that it 
provides to make xml-rpc calls from javscript to Zope. 

>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 6/29/00, 10:14:06 AM, Hung Jung Lu <hungjunglu@hotmail.com> wrote 
regarding Re: [Zope-dev] Using Java-Script with DTML:


> --- In zope@egroups.com, Thomas Weholt <Thomas@c...> wrote:
> ><script language="javascript1.2>
> >
> >function ShowStuff(params){
> >
> >     var text = "<dtml-in expr="sqlMethod(some_id=params>" <!-- this does
> >not work, of course. How I can I pass argument thru Javascript to the
> >sqlMethod ?? --->
> >     alert (text);
> >}
> >
> ></script>

> I think I know what you are talking about. But you have to really
> keep your mind straight about one thing: DTML runs with the CPU
> on the server side, JavaScript runs with the CPU on the client side.
> In other words, by the time you are running Javascript, you
> CAN'T access your database records.

> I have done a lot of things in displaying dynamic pull-down menus.
> E.g: you choose a state from one pull down menu, and the content
> of another pulldown menu is automatically changed to the list of
> cities within that particular state. When you click on a state,
> you CAN'T query your database for the list of its cities. It's
> too late, your code is already running on the client side. So
> what should you do? What you should do is to pre-generate
> JavaScript arrays, storing the names of all the cities for all
> the states.

> That being said, there is one more caveat. When you pre-render
> your database records into JavaScript arrays, you have to be
> careful about quoting. I don't know whether there are any string
> format quoting in DTML suitable for rendering into JavaScript
> (the <dtml-sqltest ... type=string> comes to mind, but I am not
> sure it works outside ZSQL methods), I ended up implementing my
> own external method to quote Python strings into JavaScript strings.

> If you still don't understand what I mean, consider a python string

>     'He said, "no".'

> stored in your DTML variable mystring, that is, something like:

>     <dtml-call "REQUEST.set('mystring', 'He said, "no".')">

> and you pre-render it into JavaScript code

>     x = "<dtml-var mystring>";

> It won't work. Because if you look at the source of your JavaScript,
> you will see:

>     x = "He said, "no".";

> regards,

> Hung Jung

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


> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )