variables declared within any blocks like if ,while etc, have a scope
within that block only. Varibles declared outside any functions,subs etc. has a page wide scope.
HTH
Faustine
--------
: Hi,
:
: It worked perfectly fine. I thought I can declare the array inside the if block because it is used only when the form is submitted. Could you please clarify
:
: thanks
:
:
: : Declare the array outside the if block.
: :
: : <%
: : dim arrError(15)
: : if Request.Form("Submit")="Submit" then
: :
: :
: :
: :
: : HTH
: : Faustine
: : --------
: : : Hi,
: : :
: : : I'm trying to validate a form by posting the ASP page to itself. I'm trying to check the length of
: : :
: : : textfields, and flag the fields which have zero size, and then change the font color selectively. But
: : :
: : : when I try to change the font color I get a 'type mismatch error'.
: : :
: : : Here is my code
: : :
: : :
: : : <%
: : : if Request.Form("Submit")="Submit" then
: : : dim arrError(15)
: : :
: : :
: : : For i =0 to 15-1
: : : arrError(i)=False
: : : NEXT
: : :
: : : dim StrText
: : : Const STRFIELDS=15, NUMFIELDS=4
: : : For i= 0 to STRFIELDS-1
: : : StrText=Cstr(GetFname(i))
: : : If Len(Request.Form(StrText))=0 Then
: : : arrError(i)=TRUE
: : : End If
: : : Next
: : : End If
: : :
: : : Function GetFname(x)
: : : Select Case x
: : : Case 0
: : : GetFname="lname"
: : : Case 1
: : : GetFname="fname"
: : : Case 2
: : : GetFname="minitial"
: : : Case 3
: : : GetFname="mrecno"
: : : Case 4
: : : GetFname="age"
: : : Case 5
: : : GetFname="Sex"
: : : Case 6
: : : GetFname="dob_date"
: : : Case 7
: : : GetFname="dob_year"
: : : Case 8
: : : GetFname="exam_date"
: : : Case 9
: : : GetFname="exam_year"
: : : Case 10
: : : GetFname="reasonfordiag"
: : : Case 11
: : : GetFname="diffdiag"
: : : Case 12
: : : GetFname="mjrfind"
: : : Case 13
: : : GetFname="mnrfind"
: : : Case 14
: : : GetFname="technote"
: : : End Select
: : : End Function
: : :
: : : %>
: : :
: : : <html>
: : : <head>
: : :
: : : </table>
: : : <table width="537" height="266" border="0" cellpadding="2" cellspacing="0">
: : : <tr bordercolor="0">
: : : <td width="176" height="26"><font <% if arrError(0) then %> style="color:red;" <% end if
: : :
: : : %>>Last Name</font></td>
: : : <td width="353">
: : : <input name="lname" type="text" id="lname">
: : : </td>
: : : </tr>
: : :
: : : ...
: : : ...
: : : ...
: : :
: : : Please help !
: : :
: : : Thanks
: : :
: : : Senthil
: : :
: : :
: :
: :
:
: