Click to See Complete Forum and Search --> : If Then problem


stevem2004
02-23-2005, 09:05 AM
Hi,

Can somebody tell me what is wrong with the code below, as it just doesn't work

<%
Dim StatusType

StatusType = Request("status")

If StatusType = Approved Then %>
<!-- #include file="sendmail_tb_auth.inc" -->
<% Else If StatusType = Refused Then %>
<!-- #include file="sendmail_tb_fail.inc" -->
<% End If %>
<% End If %>


TIA
Steve

lmf232s
02-23-2005, 09:12 AM
<% Else If StatusType = Refused Then %>

should be

<%ElseIf StatusType%>

Remove the space between ELse & If

Well i guess i should ask what the problem is because, its fine the way you have it, it just would be a "if" nested inside a "if" but if you wanted to use "elseif" then its wrong.

What is happening or not happening?

stevem2004
02-23-2005, 09:23 AM
The problem is that the emails are not being sent.

As you might have gathered from the script I am trying to do the following; if StatusType = Approved then send approval email, if StatusType = Refused send refused email.

Could this be done another/better way?

lmf232s
02-23-2005, 10:50 AM
ok, two way to do it.

<%
Dim StatusType

StatusType = "Approved"

If StatusType = "Approved" Then%>
<!-- #include file="sendmail_tb_auth.inc" -->
<%Else
If StatusType = "Refused" Then%>
<!-- #include file="sendmail_tb_fail.inc" -->
<% End If
End If %>

or

Dim StatusType

StatusType = "Approved"

If StatusType = "Approved" Then
response.write "Approved"%>
<!-- #include file="sendmail_tb_auth.inc" -->
<%ElseIf StatusType = "Refused" Then
Response.Write "Refused"%>
<!-- #include file="sendmail_tb_fail.inc" -->
<%End If %>


either way you were missing the " " around what you were tyring to match

Dim StatusType
StatusType = "Approved"

if StatusType = Approved then

this statment will be false and will not drop in the loop,
Not sure of the correct termanology but
"Approved" is not = to Approved

Hope that helps

stevem2004
02-24-2005, 08:55 AM
Many Thanks for your help