Using query template's and javascript

bfischer at usgs.gov bfischer at usgs.gov
Wed Apr 26 13:32:44 EDT 2000


Thanks to the people who responed to my original question.  I figured out
what was causing the error in the javascipt.  It turns out I had to put an
escape character (/) in front of the parenthes used in the table tags.
Ex.)

document.write("<td width=\"25%\">[BASIN_NAME]</td>\n");

Brian Fischer
bfischer at usgs.gov
USGS WRD
2280 Woodale Dr.
Mounds View, MN
(612) 783-3133



                                                                                                                                
                                                                                                                                
                                                                                                                                
                                                                                                                                
                                                                                                                                
                                                                                                                                
                                                                                                                                


                                                                                                                                  
                    "Stephen Lime"                                                                                                
                    <steve.lime at dnr.st        To:     <bfischer at usgs.gov>                                                         
                    ate.mn.us>                cc:                                                                                 
                                              Subject:     Re: Using query template's and javascript                              
                    04/24/00 01:50 PM                                                                                             
                                                                                                                                  
                                                                                                                                  



MapServer doesn't add ANY html code itself. You must have a reference
to a blank template someplace, perhaps as a query template for a particular
type of result?

Steve

>>> <bfischer at usgs.gov> 04/24/00 01:39PM >>>
Mapserver users,

I am trying to use javascript, with a query header, footer, and template
files.  I am fairly new to javascript, but maybe other people have some
insights on what is happening.  What I am trying to do is sum polygons'
attributes, from the polygons that get returned by a query.  I am using a
query header, footer, and template to return the results to the browser
inside a HTML table.  Here is the part of the HTML files with the
JavaScript program.  I am using the program within the body of my HTML
file.  The problem is nothing happens.  The code is there when I view the
page source in Netscape.  One thing I did notice is mapserver adds this
between the header and template files.

<html>
<head>
<title>Blank page</title>
</head>
<body>
</body>
</html>

Is this whats messing up the javascript?

header file:
<table>

<script LANGUAGE="JavaScript">
<!-- This script sums the area and writes it to HTML

var tam=0.0 ;

tam
=[wsareami] ;

query template

tam=tam+[AREA_SQ_MI] ;

document.write("<tr>
\n") ;
document.write("<td width="25%">[MAJOR]</td>\n") ;
document.write
("<td width="25%">[AREA_SQ_MI]</td>\n") ;
document.write("</tr>\n") ;
query footer

document.write("Total Area is: ") ;
document.write(tam) ;
//-->
</script>
</table>

Thanks,

Brian Fischer
bfischer at usgs.gov
USGS WRD
2280 Woodale Dr.
Mounds View, MN
(612) 783-3133










More information about the mapserver-users mailing list