|
 |
asp_web_howto thread: IsDefined() ?
Message #1 by Ruben Chadien <ruben.chadien@m...> on Mon, 27 Aug 2001 16:23:31 +0200
|
|
Hi, i wondering how you could check if a form or queryString variable
exists, i know you can do like
<%
if request.form("myVar") = "" then
end if
%>
but with this method i don't know if the varible exists or if it has the
value of ""
/TIA Ruben Chadien
Message #2 by Kyle Burns <kburns@c...> on Mon, 27 Aug 2001 13:08:57 -0500
|
|
You must be a Cold Fusion convert!
I just mocked up a function that should do what you need. Here's a sample
page to try it out. Hope it helps.
<% @LANGUAGE="VBScript" %>
<% Option Explicit %>
<HTML>
<HEAD>
<TITLE>Test IsDefined()</TITLE>
</HEAD>
<BODY>
<H1 ALIGN="center">
<%
If Request("txtDefined") > "" Then
If IsDefined(Request("txtDefined")) Then
Response.Write "Variable Is Defined"
Else
Response.Write "Variable Is Not Defined"
End If
End If
%>
</H1>
<FORM ACTION="<% =Request.ServerVariables("SCRIPT_NAME") %>" METHOD="POST">
<INPUT TYPE="text" NAME="txtDefined"><BR>
<INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>
<%
Function IsDefined(VariableName)
'You could also loop through the querystring
'here, but I wanted to keep it simple.
Dim bResult
Dim var
bResult = False
For Each var In Request.Form
If UCase(var) = UCase(VariableName) Then
bResult = True
Exit For
End If
Next 'var
IsDefined = bResult
End Function
%>
=================================
Kyle M. Burns, MCSD
ECommerce Technology Manager
Centra Credit Union
kburns@c...
-----Original Message-----
From: Ruben Chadien [mailto:ruben.chadien@m...]
Sent: Monday, August 27, 2001 9:24 AM
To: ASP Web HowTo
Subject: [asp_web_howto] IsDefined() ?
Hi, i wondering how you could check if a form or queryString variable
exists, i know you can do like
<%
if request.form("myVar") = "" then
end if
%>
but with this method i don't know if the varible exists or if it has the
value of ""
/TIA Ruben Chadien
|
|
 |