动态产生变量
类别: ASP教程
<%
how_many=50
mycreate = request.querystring("create")
If mycreate = "" Then
%><TITLE>Dynamically Generate Variables</TITLE>
<BODY bgcolor="#FFFFFF">
<FORM method="post" action="dyn_gen_variables.asp?create=1">
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><B>Dynamically Generate
Variables </B><BR>
<BR>
Variable Name: </FONT>
<INPUT type="text" name="variablename">
<BR>
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2">Request Type: </FONT>
<INPUT type="radio" name="requesttype" value="querystring" checked>
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2">Querystring</FONT>
<INPUT type="radio" name="requesttype" value="form">
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2">Form </FONT><BR>
<BR>
<INPUT type="submit" name="Submit" value="Submit">
</FORM>
<%
else
%>
<TITLE>Dynamically Generate Variables - DONE</TITLE>
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><B>Dynamically Generate
Variables</B></FONT> - DONE<BR>
<BR>
<BR>
<%
variablename = request.form("variablename")
requesttype = request.form("requesttype")
mycounter = 0
Do While mycounter < how_many
myvaroutput = myvaroutput & variablename & mycounter & " = replace(request." & requesttype & "(" & chr
(34) & variablename & mycounter & chr(34) & "), " & chr(34) & "\'" &chr(34) & ", " &chr(34) & "\'\'" & chr
(34) & ")"
myvaroutput = myvaroutput & "<BR>"
myvaroutput2 = myvaroutput2 & variablename & mycounter & " = TRIM(" & variablename & mycounter & ")"
myvaroutput2 = myvaroutput2 & "<BR>"
mycounter = mycounter + 1
loop
response.write "<FONT face=\'arial\' size=\'2\'>"
response.write "\' Get VARIABLES AND REPLACE APOSTROPHES With Double APOSTROPHES<BR>"
response.write myvaroutput
response.write "<BR><BR>"
response.write "\' TRIM ALL TEH SPACES OUT OF THE VARIABLES<BR>"
response.write myvaroutput2
response.write "</FONT>"
%> <%
End If
%>
</BODY>
</HTML>
how_many=50
mycreate = request.querystring("create")
If mycreate = "" Then
%><TITLE>Dynamically Generate Variables</TITLE>
<BODY bgcolor="#FFFFFF">
<FORM method="post" action="dyn_gen_variables.asp?create=1">
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><B>Dynamically Generate
Variables </B><BR>
<BR>
Variable Name: </FONT>
<INPUT type="text" name="variablename">
<BR>
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2">Request Type: </FONT>
<INPUT type="radio" name="requesttype" value="querystring" checked>
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2">Querystring</FONT>
<INPUT type="radio" name="requesttype" value="form">
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2">Form </FONT><BR>
<BR>
<INPUT type="submit" name="Submit" value="Submit">
</FORM>
<%
else
%>
<TITLE>Dynamically Generate Variables - DONE</TITLE>
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><B>Dynamically Generate
Variables</B></FONT> - DONE<BR>
<BR>
<BR>
<%
variablename = request.form("variablename")
requesttype = request.form("requesttype")
mycounter = 0
Do While mycounter < how_many
myvaroutput = myvaroutput & variablename & mycounter & " = replace(request." & requesttype & "(" & chr
(34) & variablename & mycounter & chr(34) & "), " & chr(34) & "\'" &chr(34) & ", " &chr(34) & "\'\'" & chr
(34) & ")"
myvaroutput = myvaroutput & "<BR>"
myvaroutput2 = myvaroutput2 & variablename & mycounter & " = TRIM(" & variablename & mycounter & ")"
myvaroutput2 = myvaroutput2 & "<BR>"
mycounter = mycounter + 1
loop
response.write "<FONT face=\'arial\' size=\'2\'>"
response.write "\' Get VARIABLES AND REPLACE APOSTROPHES With Double APOSTROPHES<BR>"
response.write myvaroutput
response.write "<BR><BR>"
response.write "\' TRIM ALL TEH SPACES OUT OF THE VARIABLES<BR>"
response.write myvaroutput2
response.write "</FONT>"
%> <%
End If
%>
</BODY>
</HTML>
- 上一篇: 表示代码与逻辑代码分离
- 下一篇: 计算当前日期是任意时间段内第几周的函数
-= 资 源 教 程 =-
文 章 搜 索