1.2 サーバ側でアンケート回答データを受け取る
■アンケート・ページから入力データを受け取る
リスト1.3 receive.asp
<%@ LANGUAGE="VBScript" %>
<% Option Explicit %>
<HTML>
<HEAD>
<TITLE>receive.asp</TITLE>
</HEAD>
<BODY>
<%
Dim intQ1,intQ21,intQ22,intQ23,intQ24,strQ24,strQ3
intQ1 = Request.Form("Q1")
intQ21 = Request.Form("Q21")
intQ22 = Request.Form("Q22")
intQ23 = Request.Form("Q23")
intQ24 = Request.Form("Q24")
strQ24 = Request.Form("Q24txt")
strQ3 = Request.Form("Q3")
%>
</BODY>
</HTML>
■デバグ用に受信データを表示する
リスト1.4 receive2.asp
<%@ LANGUAGE="VBScript" %>
<% Option Explicit %>
<HTML>
<HEAD>
<TITLE>receive2.asp</TITLE>
</HEAD>
<BODY>
<%
Const FOR_DEBUG = "<BR>Debug(receive2.asp): "
Dim intQ1,intQ21,intQ22,intQ23,intQ24,strQ24,strQ3
intQ1 = Request.Form("Q1")
intQ21 = Request.Form("Q21")
intQ22 = Request.Form("Q22")
intQ23 = Request.Form("Q23")
intQ24 = Request.Form("Q24")
strQ24 = Request.Form("Q24txt")
strQ3 = Request.Form("Q3")
Response.Write FOR_DEBUG & "intQ1=" & intQ1 & "<BR>"
Response.Write FOR_DEBUG & "intQ21=" & intQ21 & "<BR>"
Response.Write FOR_DEBUG & "intQ22=" & intQ22 & "<BR>"
Response.Write FOR_DEBUG & "intQ23=" & intQ23 & "<BR>"
Response.Write FOR_DEBUG & "intQ24=" & intQ24 & "<BR>"
Response.Write FOR_DEBUG & "strQ24=" & strQ24 & "<BR>"
Response.Write FOR_DEBUG & "strQ3=" & strQ1 & "<BR>"
%>
</BODY>
</HTML>
リスト1.4を実行する前に、リスト1.2の09行目を
09 <FORM ACTION="receive.asp" METHOD="post">
から
09 <FORM ACTION="receive2.asp" METHOD="post">
に変更しておきます。つまり、アンケートページで「OK」ボタンをクリックしたときに起動されるファイルを"receive2.asp"に変更しておく必要があります。
図1.3
■Request.Form()の省略形
Request.Form()はRequest()のように".Form"の部分を省略して記述することができます。
リスト1.3はリスト1.5のように簡単化できます。
リスト1.5 receive3.asp
<%@ LANGUAGE="VBScript" %>
<% Option Explicit %>
<HTML>
<HEAD>
<TITLE>receive3.asp</TITLE>
</HEAD>
<BODY>
<%
Dim intQ1,intQ21,intQ22,intQ23,intQ24,strQ24,strQ3
intQ1 = Request("Q1")
intQ21 = Request("Q21")
intQ22 = Request("Q22")
intQ23 = Request("Q23")
intQ24 = Request("Q24")
strQ24 = Request("Q24txt")
strQ3 = Request("Q3")
%>
</BODY>
</HTML>