[Zope] Changing REQUEST in a javascript
Passin,Thomas B. (Tom)
tpassin@mitretek.org
Thu, 19 Sep 2002 14:37:32 -0400
[ Dag Nygren]
>=20
> > Another method is to have Zope put all of the potential=20
> choices in the=20
> > second
> > select box into the Javascript code that gets sent to the=20
> client. You could=20
> > use an associative array to do this. Then populate the=20
> second select box with=20
> > the items in that key of the Javascript associative array.=20
> This method works=20
> > good only when the total number of items is relatively=20
> small in both selects=20
> > and doesn't change very often.
>=20
> This is probably not a good idea in my case as I in the final=20
> page will have 5 SELECTS with 4-10 alternatives that are=20
> dependant on each other. The total number of permutations is too high.
>=20
Do not be too quick to discard the option. You can probably write a
Zope page or script that would generate the alternatives automatically,
and the number of Javascript objects would be low enough so that
performance would be very good. You should read up on how to create
arbitrary Javascript objects using function(), because it lets you do
some very neat things quite easily.
I have created several pages where the page contains data, and
javascript populates several select lists after the page has loaded.
One thing to know if you plan to change the contents of a select list
after the page has loaded. Netscape 4xx browsers cannot change the page
layout once the page has loaded. Therefore you have to make sure that
your select boxes are wide enough when the page first loads. One way to
do that is to give them a dummy option, such as=20
<option>-------------------------------------
You can replace that option when you reload them later. Later browsers
(e.g., IE5+ and Mozilla) can resize the select boxes and you do not have
to do this hack.
Cheers,
Tom P