If / Then / Else Help Needed - More then one condition possible?

T

tbird2340

I want to write an if / then statement and have tried using this:

var MyVarMailto;
if (Request.Form("LoanRequest") == "Under $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "(e-mail address removed)";
}
}
else if (Request.Form("LoanRequest") == "Over $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "(e-mail address removed)";
}
}
else {
MyVarMailto = "(e-mail address removed)";
}

So basically I have a form that gets filled out and submitted which
passes the values to this page. I want to check the values against
conditions that you can probably figure out above and then set the
variable contigent to those values. I tried using AND after the first
condition but that doesn't do anything. Please help. Thanks so much.
 
V

VK

var MyVarMailto;
if (Request.Form("LoanRequest") == "Under $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "(e-mail address removed)";
}
}
else if (Request.Form("LoanRequest") == "Over $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "(e-mail address removed)";
}
}
else {
MyVarMailto = "(e-mail address removed)";
}

what object is Request? what object is Form? what object is LoanRequest
(select list, textbox, radiogroup)?
 
V

VK

var MyVarMailto;
if (Request.Form("LoanRequest") == "Under $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "(e-mail address removed)";
}
}
else if (Request.Form("LoanRequest") == "Over $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "(e-mail address removed)";
}
}
else {
MyVarMailto = "(e-mail address removed)";
}

what object is Request? what object is Form? what object is LoanRequest
(select list, textbox, radiogroup)?
 
K

Kevin Darling

if (Request.Form("LoanRequest") == "Under $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "(e-mail address removed)";
}
}
[...] . I tried using AND after the first
condition but that doesn't do anything. Please help. Thanks so much.

if ((Request.Form("LoanRequest") == "Under $250,000") &&
(Request.Form("Organization") == "1") )
MyVarMailto = "(e-mail address removed)";
else
if ...

&& = AND, || = OR

Kev
 
M

McKirahan

I want to write an if / then statement and have tried using this:

var MyVarMailto;
if (Request.Form("LoanRequest") == "Under $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "(e-mail address removed)";
}
}
else if (Request.Form("LoanRequest") == "Over $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "(e-mail address removed)";
}
}
else {
MyVarMailto = "(e-mail address removed)";
}

So basically I have a form that gets filled out and submitted which
passes the values to this page. I want to check the values against
conditions that you can probably figure out above and then set the
variable contigent to those values. I tried using AND after the first
condition but that doesn't do anything. Please help. Thanks so much.

JScript and ASP, eh? Perhaps this is what you want:

var MyVarMailto = (e-mail address removed);
var MyAmt = "<%=Request.Form("LoanRequest")%>";
var MyOrg = "<%=Request.Form("Organization")%>";

if (MyOrg == "1") {
if (MyAmt == "Under $250,000") {
MyVarMailto = "(e-mail address removed)";
} else if (MyAmt == "Over $250,000") {
MyVarMailto = "(e-mail address removed)";
}
}
 
T

tbird2340

Yes, Jscript and ASP.. I know. I don't like it either but it's the only
site I setup like this the rest are VB and asp..

I tried a couple of the suggestions. It seems like for whatever reason
the variable isn't getting set.

I tried using this:

var MyVarMailto;
if ((Request.Form("LoanRequest") == "Under $250,000") &&
(Request.Form("Organization") == "1")) {
MyVarMailto = "(e-mail address removed)";
}
else if ((Request.Form("LoanRequest") == "Over $250,000") &&
(Request.Form("Organization") == "1")) {
MyVarMailto = "(e-mail address removed)";
}
else {
MyVarMailto = "(e-mail address removed)";

And also this:

var MyVarMailto = "(e-mail address removed)";
var MyAmt = Request.Form("LoanRequest");
var MyOrg = Request.Form("Organization");

if (MyOrg == "1") {
if (MyAmt == "1") {
MyVarMailto = "(e-mail address removed)";
} else if (MyAmt == "2") {
MyVarMailto = "(e-mail address removed)";
}
}

I shouldn't say the variable isn't getting set.. It's acting like none
of the conditions are matching and it's using the "ELSE" email
address.. The values are getting passed and that's why I'm confused.
Any ideas? Thanks!
 
M

McKirahan

Yes, Jscript and ASP.. I know. I don't like it either but it's the only
site I setup like this the rest are VB and asp..

I tried a couple of the suggestions. It seems like for whatever reason
the variable isn't getting set.

I tried using this:

var MyVarMailto;
if ((Request.Form("LoanRequest") == "Under $250,000") &&
(Request.Form("Organization") == "1")) {
MyVarMailto = "(e-mail address removed)";
}
else if ((Request.Form("LoanRequest") == "Over $250,000") &&
(Request.Form("Organization") == "1")) {
MyVarMailto = "(e-mail address removed)";
}
else {
MyVarMailto = "(e-mail address removed)";

And also this:

var MyVarMailto = "(e-mail address removed)";
var MyAmt = Request.Form("LoanRequest");
var MyOrg = Request.Form("Organization");

if (MyOrg == "1") {
if (MyAmt == "1") {
MyVarMailto = "(e-mail address removed)";
} else if (MyAmt == "2") {
MyVarMailto = "(e-mail address removed)";
}
}

I shouldn't say the variable isn't getting set.. It's acting like none
of the conditions are matching and it's using the "ELSE" email
address.. The values are getting passed and that's why I'm confused.
Any ideas? Thanks!

Are you sure? Insert the following line after the "var" statements:
alert("MyAmt=" + MyAmt + "\nMyOrg = " + MyOrg);
what do you see?

You may have to post a stripped version of your code.

Does your page's filename have an ".asp" extension.
 
L

Lee

(e-mail address removed) said:
Yes, Jscript and ASP.. I know. I don't like it either but it's the only
site I setup like this the rest are VB and asp..

I tried a couple of the suggestions. It seems like for whatever reason
the variable isn't getting set.

I tried using this:

var MyVarMailto;
if ((Request.Form("LoanRequest") == "Under $250,000") &&
(Request.Form("Organization") == "1")) {
MyVarMailto = "(e-mail address removed)";
}
else if ((Request.Form("LoanRequest") == "Over $250,000") &&
(Request.Form("Organization") == "1")) {
MyVarMailto = "(e-mail address removed)";
}
else {
MyVarMailto = "(e-mail address removed)";

And also this:

var MyVarMailto = "(e-mail address removed)";
var MyAmt = Request.Form("LoanRequest");
var MyOrg = Request.Form("Organization");

if (MyOrg == "1") {
if (MyAmt == "1") {
MyVarMailto = "(e-mail address removed)";
} else if (MyAmt == "2") {
MyVarMailto = "(e-mail address removed)";
}
}

I shouldn't say the variable isn't getting set.. It's acting like none
of the conditions are matching and it's using the "ELSE" email
address.. The values are getting passed and that's why I'm confused.
Any ideas? Thanks!

Is this code executed on the client, or on the server?
The client won't have a "Request" object, and you should be seeing error
messages saying so.

Is the code you've shown us inside a function definition? If so,
are you returning MyVarMailto? It's declared as a local variable,
so it won't be seen outside the function.


--
 
T

tbird2340

Hope you don't mind but I emailed you two ASP pages to the email
address you have on this site. Figured it would be easier for you to
see the entire code. Thanks
 
M

McKirahan

Hope you don't mind but I emailed you two ASP pages to the email
address you have on this site. Figured it would be easier for you to
see the entire code. Thanks

What would be "easier" for me would be to see less code.

Try stripping the code down to the fewest lines that still has the
problem. In this effort you may discover the problem yourself.

If you haven't found the problem then post this code to the newsgroup.

P.S. I accidentally deleted your email because it had an attachment.
 
T

tbird2340

Ok here's the deal. The if/then/else code works fine.. What the problem
seems to be is that when I put the cdonts code inside the "insert
record" code the variable isn't getting the correct value.. However, if
I put the cdonts code anywhere else the variable gets the correct value
assinged to it.

I have many pages setup with this same cdonts code and set in the same
place. Totally stumped...
 
M

McKirahan

Ok here's the deal. The if/then/else code works fine.. What the problem
seems to be is that when I put the cdonts code inside the "insert
record" code the variable isn't getting the correct value.. However, if
I put the cdonts code anywhere else the variable gets the correct value
assinged to it.

As I've said: "You may have to post a stripped version of your code."
I have many pages setup with this same cdonts code and set in the same
place. Totally stumped...

Use an "include" file with the "same cdonts code" and change it once.
<!--#include file="CDO_Code.asp"-->

Construct the "body" in a variable then pass it in to a "include" function:

email("(e-mail address removed)",MyVarMailto,"BFS Loan Referral",MyVarBody)

// CDO_Code.asp
function email(eFrom,eTo,eSubj,eBody)
var cdomail;
cdomail = Server.CreateObject("cdonts.newmail");
cdomail.from = eFrom;
cdomail.to = eTo;
cdomail.subject = eSubj;
cdomail.body = eBody;
cdomail.MailFormat = 0;
cdomail.BodyFormat = 0;
cdomail.send();
}

Prepare a standalone page to test it:

<% @Language="JScript" %>
<!--#include file="CDO_Code.asp"-->
<html>
<head>
<title>CDO_Test.asp</title>
<% var eFrom = "(e-mail address removed)";
var eTo = "... an email address ...;
var eSubj = "BFS Loan Referral";
var eBody = "... HTML source code ...";
email(eFrom,eTo,eSubj,eBody)
%>
</head>
</body>
</html>

I haven't tested this; also, I normally do server-side in VBScript.

CDO.Message() has replaced CDONTS.NewMail():
How do I send e-mail with CDO?
URL:http://classicasp.aspfaq.com/email/how-do-i-send-e-mail-with-cdo.html


Also, what if someone wants a loan of exactly $250,000?

Size of Loan Request:&nbsp;
<select name="LoanRequest" id="LoanRequest">
<option value="null" selected>Select size of loan.
<option value="1">Under $250,000
<option value="2">Over $250,000
</select>

(Obviously I recovered you email and looked at the code.)
 
T

tbird2340

Thanks but that is all beyond my level.. I don't understand why this
one isn't working when all the others exactly like it are. The variable
gets set as the wrong value when it's inside the insert code but gets
set correctly when outside of it? I don't get it..

What's even weirder is I can see the variable is gettin set correctly
even when it's inside the insert code but for some reason it's not
seeing that?

How can this be explained?
 
M

McKirahan

Thanks but that is all beyond my level.. I don't understand why this
one isn't working when all the others exactly like it are. The variable
gets set as the wrong value when it's inside the insert code but gets
set correctly when outside of it? I don't get it..

What's even weirder is I can see the variable is gettin set correctly
even when it's inside the insert code but for some reason it's not
seeing that?

How can this be explained?

Please quote what you are referring to.

" ... isn't working ..." is not very helpful...

It may be beyond your level now but just give it a try:

Cut-and-paste my code to create two files:
CDO_Code.asp and CDO_Test.asp
post it to your Web server and visit CDO_Test.asp

What happens?


Also, since your original Subject line was
"If / Then / Else Help Needed"
and in a recent post you stated:
"The if/then/else code works fine."
then perhaps you should start a new post
with your new peoblem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top