By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,181 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

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

P: n/a
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 = "em****@address.com";
}
}
else if (Request.Form("LoanRequest") == "Over $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "em****@address.com";
}
}
else {
MyVarMailto = "em****@address.com";
}

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.

Sep 19 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a
VK

tb*******@gmail.com wrote:
var MyVarMailto;
if (Request.Form("LoanRequest") == "Under $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "em****@address.com";
}
}
else if (Request.Form("LoanRequest") == "Over $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "em****@address.com";
}
}
else {
MyVarMailto = "em****@address.com";
}
what object is Request? what object is Form? what object is LoanRequest
(select list, textbox, radiogroup)?

Sep 19 '06 #2

P: n/a
VK

tb*******@gmail.com wrote:
var MyVarMailto;
if (Request.Form("LoanRequest") == "Under $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "em****@address.com";
}
}
else if (Request.Form("LoanRequest") == "Over $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "em****@address.com";
}
}
else {
MyVarMailto = "em****@address.com";
}
what object is Request? what object is Form? what object is LoanRequest
(select list, textbox, radiogroup)?

Sep 19 '06 #3

P: n/a
tb*******@gmail.com wrote:
if (Request.Form("LoanRequest") == "Under $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "em****@address.com";
}
}
[...] . 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 = "em****@address.com";
else
if ...

&& = AND, || = OR

Kev

Sep 19 '06 #4

P: n/a
<tb*******@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
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 = "em****@address.com";
}
}
else if (Request.Form("LoanRequest") == "Over $250,000") {
if (Request.Form("Organization") == "1") {
MyVarMailto = "em****@address.com";
}
}
else {
MyVarMailto = "em****@address.com";
}

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 = em****@address.com;
var MyAmt = "<%=Request.Form("LoanRequest")%>";
var MyOrg = "<%=Request.Form("Organization")%>";

if (MyOrg == "1") {
if (MyAmt == "Under $250,000") {
MyVarMailto = "em****@address.com";
} else if (MyAmt == "Over $250,000") {
MyVarMailto = "em****@address.com";
}
}
Sep 19 '06 #5

P: n/a
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 = "em****@zoominternet.net";
}
else if ((Request.Form("LoanRequest") == "Over $250,000") &&
(Request.Form("Organization") == "1")) {
MyVarMailto = "em****@fpfc.net";
}
else {
MyVarMailto = "em****@gmail.com";

And also this:

var MyVarMailto = "em****@fpfc.net";
var MyAmt = Request.Form("LoanRequest");
var MyOrg = Request.Form("Organization");

if (MyOrg == "1") {
if (MyAmt == "1") {
MyVarMailto = "em****@zoominternet.net";
} else if (MyAmt == "2") {
MyVarMailto = "em****@gmail.com";
}
}

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!

Sep 20 '06 #6

P: n/a
<tb*******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
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 = "em****@zoominternet.net";
}
else if ((Request.Form("LoanRequest") == "Over $250,000") &&
(Request.Form("Organization") == "1")) {
MyVarMailto = "em****@fpfc.net";
}
else {
MyVarMailto = "em****@gmail.com";

And also this:

var MyVarMailto = "em****@fpfc.net";
var MyAmt = Request.Form("LoanRequest");
var MyOrg = Request.Form("Organization");

if (MyOrg == "1") {
if (MyAmt == "1") {
MyVarMailto = "em****@zoominternet.net";
} else if (MyAmt == "2") {
MyVarMailto = "em****@gmail.com";
}
}

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.
Sep 20 '06 #7

P: n/a
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

Sep 20 '06 #8

P: n/a
It's server side and not inside a function..
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.
--
Sep 20 '06 #9

P: n/a
<tb*******@gmail.comwrote in message
news:11*********************@m7g2000cwm.googlegrou ps.com...
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.
Sep 20 '06 #10

P: n/a
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...

Sep 20 '06 #11

P: n/a
<tb*******@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
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("BF**************@fpfc.net",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 = "BF**************@fpfc.net";
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/h...-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.)
Sep 20 '06 #12

P: n/a
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?

Sep 20 '06 #13

P: n/a
<tb*******@gmail.comwrote in message
news:11**********************@d34g2000cwd.googlegr oups.com...
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.
Sep 20 '06 #14

P: n/a
Ok. Thanks for the help.

Sep 21 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.