473,473 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
14 2149
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
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
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
<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
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
<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
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
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
<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
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
<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
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
<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
Ok. Thanks for the help.

Sep 21 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: dmbkiwi | last post by:
I am new to this group, and relatively new to python programming, however, have encountered a problem I just cannot solve through reading the documentation, and searching this group on google. I...
23
by: Invalid User | last post by:
While trying to print a none empty list, I accidentaly put an "else" statement with a "for" instead of "if". Here is what I had: if ( len(mylist)> 0) : for x,y in mylist: print x,y else:...
33
by: Diez B. Roggisch | last post by:
Hi, today I rummaged through the language spec to see whats in the for ... else: for me. I was sort of disappointed to learn that the else clauses simply gets executed after the loop-body -...
27
by: Ron Adam | last post by:
There seems to be a fair amount of discussion concerning flow control enhancements lately. with, do and dowhile, case, etc... So here's my flow control suggestion. ;-) It occurred to me (a...
3
by: Patrice | last post by:
Hi, I need to do multi-conditional statements like below, but this error is displayed : Expected 'End' /myFilepath, line x else response.write(arrCorpo(sparam,sdiv)) end if I don't...
2
by: misscrf | last post by:
I have a search form that is great. I have modified it in such a way, that when search results come up I can bring it back to a useful spot, say an entry form or a report. Here is my lemon (...
1
by: pereges | last post by:
in my program i have a piece of code like this - int left_count, right_count; left_count = right_count = 0; for all triangles { a = condition that x coordinates of all vertices are <=...
11
by: Chad | last post by:
The question stems from some code at the following url http://www.cplusplus.com/reference/clibrary/cstdio/fread.html In the code example they have a single if statement for the following ...
10
by: arcticool | last post by:
I was just surprised to find that "Else if" is not required in the code bit below. Apparently "If" and "Else if" are used interchangeably. Please correct me if I'm wrong, but it appears "Else" is...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.