Rob Boyd wrote:
I'm stuck this, and would appreciate help or pointers.
I have a form with 2 selection drop-downs. I want the user's choice of
select 1 to drive the options displayed in select 2. When the user
makes a selection in select 1, onChange calls a Javascript function
that should write select 2 options based on the result of a call to a
Python script, passing the select 1 choice as an argument to the Python
script.
But: I cannot get the Javascript var into the namespace that the TALES
expression knows about.
Example:
<script>
function makeDropDown() {
var widget = document.getElementById('select1');
var choice = widget.options[widget.selectedIndex].value;
var data = [result of calling Python script 'foo(arg)' with
arg=choice]
This is impossible, at least in a single request. You are trying to mix
server-side and client-side actions.
You would have to make a new request on the server with the contents of
'choice' in order to get it processed. This can be done with XML-RPC or
some other options; look up 'AJAX' to get a feel for this.
Alternately, if you have a known list of values for 'choice' you could
generate all the 'data' values for each 'choice' value, encode them in
the page's javascript, and look them up client-side.
--jcc
--
"Building Websites with Plone"
http://plonebook.packtpub.com/
Enfold Systems, LLC
http://www.enfoldsystems.com
_______________________________________________
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )