Creating Report Scripts with ASP
|
127
Creating the Report Scripts
Next we’ll create the three ASP files
getpoint.asp
,
showform.asp
, and
insert.asp
.
The first file,
getpoint.asp
, creates a small browser window and then calls a
second file,
showform.asp
, passing along the coordinate values it received
from Autodesk MapGuide:
<SCRIPT language="JavaScript">
window.close( );
var loc = "showform.asp?LAT=" + "<%=Request.Form("lat")%>"
+ "&LON=" + "<%=Request.Form("lon")%>";
win = window.open(loc,"ShowFormWin",
"width=300,height=170,dependent=yes,resizable=yes");
win.focus();
</SCRIPT>
Note that
getpoint.asp
consists of a single
<SCRIPT>
element containing a
block of JavaScript code; because the file doesn’t display any text, no other
HTML tags are needed. Let’s look at the code line by line.
When
getpoint.asp
is first called it uses a default browser window similar to
the one in the previous example. The first line of code closes that window.
Note
Because
the browser parses the entire
<SCRIPT>
block before running
the first line of code, we can safely close the window, knowing our script will con-
tinue to run. Be aware, however, that this strategy will get you into trouble if your
file contains function calls or other multiple
<SCRIPT>
blocks. See your
JavaScript documentation for more information.
The next line constructs a URL and assigns it to a variable called
loc
. Note
that the line is a mix of both JavaScript and ASP code. The ASP code is
processed first, on the server. Then the line is sent to the browser as standard
JavaScript. Let’s look at how it works.
As you might recall from the previous example, ASP variables use the stan-
dard ASP script tags (
<%
and
%>
), as well as an equal sign that tells ASP to
substitute the actual value for the variable. In this case, the variables hold the
values
Request.Form("lat")
and
Request.Form("lon")
, both of
which refer to
Request.Form
, the ASP Request object’s Form collection. The
Request object is used by ASP to parse submitted data received from a client
as part of a URL.
Form
is a collection representing HTML form parameters
transmitted via the HTTP POST method; these parameters can be accessed
from the collection by name. In this case, the collection has two members:
the
LAT
and
LON
parameters that were posted to the file by the Autodesk
MapGuide Viewer. After the ASP code is processed, a line similar to the
following is sent to the browser:
var loc = "showform.asp?LAT=" + "37.721" + "&LON=" + "-121.943";
Summary of Contents for 15606-011408-9300 - MAP R6.3 UPG
Page 1: ...15306 010000 5060 October 2001 Autodesk MapGuide Release 6 Developer s Guide ...
Page 6: ...vi ...
Page 16: ...16 ...
Page 30: ...30 ...
Page 84: ...84 ...
Page 134: ...134 ...
Page 202: ...202 ...