Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1751
Number of posts: 4473

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
new bie question Posted by senthilpr_in on 19 Jun 2003 at 10:58 AM
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

Report
Re: new bie question Posted by faustinegeorge on 20 Jun 2003 at 1:16 AM
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
:
:

Report
Re: new bie question Posted by senthilpr_in on 25 Jun 2003 at 10:44 AM
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
: :
: :
:
:

Report
Re: new bie question Posted by faustinegeorge on 25 Jun 2003 at 9:36 PM
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
: : :
: : :
: :
: :
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.