[Zope] handling SELECT 'onchange'
Small Business Services
toolkit at magma.ca
Thu Feb 26 11:35:43 EST 2004
From: "Jim Anderson" <ezjab at ieee.org>
> I have source code that someone original wrote in javascript and
> which I'm attempting to get running in Zope by replacing
> the javascript code with DTML and an external python method
> but my code does not work.
>
> The HTML/DTML code looks like this:
>
> <SELECT name="myselect" onchange=<dtml-var
> expr="select_handler(value)"> >
> <OPTION value="choice1">choice1</OPTION>
> <OPTION value="choice2">choice2</OPTION>
> <OPTION value="choice3">choice3</OPTION>
> </SELECT>
>
> Question 1: Should this work?
It won't work. The 'onchange' function is a browser based event and the
browser does not know anything about server-side (ie. zope) functions,
variables, etc.
> Question 2: Does it make sence to change the client side javascript code
> with
> server side DTML? It seems like it may be better to let the javascript
> code deal with the selection for efficiency.
I would stick with js for anything that you want to control while 'in' the
user's browser (ie. handle browser-based events like onmouseover, etc).
Anything that has to do with saving/storing/updating information in an
permanent/semi-permanent manner should be done on the server.
For example: use js to let the user select data and perform any data
edits/checking you want, then send the data to the server (zope) for
storage.
HTH
Jonathan
More information about the Zope
mailing list