[mapserver-users] Templates and javascript

Armin Burger armin.burger at territoriumonline.com
Fri Aug 24 04:01:06 EDT 2001


Steve,
The document.write() should take the sub-array at position 4 out of the main
array and from this sub-array take the string at position indicated by
thelanguage. When I use gFldString[thelanguage] the whole sub-array at
position 'thelanguage' is printed.

When I try another definition of the array with
   var aGem = new Array('[GEMD]', '[GEMI]', '[GEMI]');
and then
   <td><script
language=JavaScript1.2>document.write(aGem[thelanguage]);</script>
then the results are the same: the field name taken as string from the array
instead of the field value is printed.

I don't know if that is  a special behaviour of javascript. I was thinking a
string is a string, no matter if you take it out of an array or if you give
it directly.

Another problem with bi/multi-lingual applications is the map file. I'd had
to change too many map file values for class names, label fields, etc. to
include that in the url. I see following possibilities
* a map file for every language: causing redundancy but the easiest way
* creating the map file on the fly (with perl or php): don't know how to
access this map file. Any sample sites?
* using mapscript: means a complete new application.
Any other suggestions?

Thanks
Armin


> The array access syntax looks wrong. Shouldn't gFldString[4][thelanguage]
be
> gFldString[thelanguage]?

> Steve

> Stephen Lime
> Internet Applications Analyst

> Minnesota DNR
> 500 Lafayette Road
> St. Paul, MN 55155
> 651-297-2937

>>>> Armin Burger <armin.burger at territoriumonline.com> 08/23/01 03:36AM >>>
> I got problems when trying to change query template contents using
> javascript. In the header template I created an array with the dBase field
> names.
> ....
> gFldString = new Array();
> ...
> gFldString[4] = ['[GEMD]', '[GEMI]', '[GEME]'];
> ....

> Then in the query template I wanted to change the field based on another
> variable (here the language for a multilingual application). I put in the
> template

> ...
> <td>[AREA]</td>
> <td><script
language=JavaScript>document.write(gFldString[4][thelanguage]);<
> /script></td>
> ...
> with "thelanguage" between 0 and 2.

> This way the field name like [GEMD] instead of the field value is written
> into the output table. When I try it with

> <td><script language=JavaScript>document.write('[GEMD]');</script></td>

> the field values are written correctly. I havent an idea why the string
> '[GEMD]' is treated different when inserted directly and when taken from
an
> array.

> Any help appreciated.

> Armin

> --
> Armin Burger
> Territorium Online
> Siemensstrasse/Via Siemens 19 - 39100 Bozen/Bolzano - Italia
> _



--
Armin Burger
Territorium Online
Siemensstrasse/Via Siemens 19 - 39100 Bozen/Bolzano - Italia
email: armin.burger at territoriumonline.com
http://www.territoriumonline.com
tel: +39-0471-568185 / fax -- 568078



More information about the mapserver-users mailing list