reading string queries into javascript

Stepan Kafka kafka at email.cz
Tue Apr 17 03:27:49 EDT 2001


You're probably right. The error is no quotes around [TDIR].  But you can
simply write

var TDIR = '[TDIR]';

because the terms in the brackets are evaluated on the server side, so
client really gets e.g.

var TDIR = 'S';

Be avare to put this javascript in external file (out of HTML template)
because it is not evaluated by mapserver.

Stepan Kafka
Kutna Hora district council
mailto:kafka at email.cz
http://www.oku-kh.cz/gis



>
> Hi,
>
> I'm having problems reading string variables from a query into javascript.
>
> T = Township (a number)
> TDIR = Township Direction ( a character 'N' or 'S')
>
> This works:
>
>    var T = [T];
>    .
>    .
>    .
>    document.write(T);
>
>
> This does not work, it comes out 'undefined':
>
>    var TDIR = [TDIR];
>    .
>    .
>    .
>    document.write(TDIR);
>
> The problem I'm guessing is with javascript wanting quotes around the
> string. Is there an escape sequence for adding quote while reading a query
> variable?
>
> Thanks a bunch,
> Chad
>
> Chad M. Nielsen, GIS Programmer/Analyst
> Tillamook County Performance Partnership (TCPP)
> Tillamook Coastal Watershed Resource Center (TCWRC)
>
>   GIS:   http://gisweb.co.tillamook.or.us
>  TCPP:
> http://www.co.tillamook.or.us/countygovernment/Estuary/homepage.ht
m
TCWRC:   http://www.tcwrc.org





More information about the mapserver-users mailing list