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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tbird2340@gmail.com

    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 = "emailA@address .com";
    }
    }
    else if (Request.Form(" LoanRequest") == "Over $250,000") {
    if (Request.Form(" Organization") == "1") {
    MyVarMailto = "emailB@address .com";
    }
    }
    else {
    MyVarMailto = "emailC@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.

  • VK

    #2
    Re: If / Then / Else Help Needed - More then one condition possible?


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

    Comment

    • VK

      #3
      Re: If / Then / Else Help Needed - More then one condition possible?


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

      Comment

      • Kevin Darling

        #4
        Re: If / Then / Else Help Needed - More then one condition possible?

        tbird2340@gmail .com wrote:
        if (Request.Form(" LoanRequest") == "Under $250,000") {
        if (Request.Form(" Organization") == "1") {
        MyVarMailto = "emailA@address .com";
        }
        }
        >[...] . I tried using AND after the first
        condition but that doesn't do anything. Please help. Thanks so much.
        if ((Request.Form( "LoanReques t") == "Under $250,000") &&
        (Request.Form(" Organization") == "1") )
        MyVarMailto = "emailA@address .com";
        else
        if ...

        && = AND, || = OR

        Kev

        Comment

        • McKirahan

          #5
          Re: If / Then / Else Help Needed - More then one condition possible?

          <tbird2340@gmai l.comwrote in message
          news:1158691576 .493446.121450@ i3g2000cwc.goog legroups.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 = "emailA@address .com";
          }
          }
          else if (Request.Form(" LoanRequest") == "Over $250,000") {
          if (Request.Form(" Organization") == "1") {
          MyVarMailto = "emailB@address .com";
          }
          }
          else {
          MyVarMailto = "emailC@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 = emailC@address. com;
          var MyAmt = "<%=Request.For m("LoanRequest" )%>";
          var MyOrg = "<%=Request.For m("Organization ")%>";

          if (MyOrg == "1") {
          if (MyAmt == "Under $250,000") {
          MyVarMailto = "emailA@address .com";
          } else if (MyAmt == "Over $250,000") {
          MyVarMailto = "emailB@address .com";
          }
          }


          Comment

          • tbird2340@gmail.com

            #6
            Re: If / Then / Else Help Needed - More then one condition possible?

            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( "LoanReques t") == "Under $250,000") &&
            (Request.Form(" Organization") == "1")) {
            MyVarMailto = "email1@zoomint ernet.net";
            }
            else if ((Request.Form( "LoanReques t") == "Over $250,000") &&
            (Request.Form(" Organization") == "1")) {
            MyVarMailto = "email2@fpfc.ne t";
            }
            else {
            MyVarMailto = "email3@gmail.c om";

            And also this:

            var MyVarMailto = "email1@fpfc.ne t";
            var MyAmt = Request.Form("L oanRequest");
            var MyOrg = Request.Form("O rganization");

            if (MyOrg == "1") {
            if (MyAmt == "1") {
            MyVarMailto = "email2@zoomint ernet.net";
            } else if (MyAmt == "2") {
            MyVarMailto = "email3@gmail.c om";
            }
            }

            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!

            Comment

            • McKirahan

              #7
              Re: If / Then / Else Help Needed - More then one condition possible?

              <tbird2340@gmai l.comwrote in message
              news:1158759276 .341401.120360@ m73g2000cwd.goo glegroups.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( "LoanReques t") == "Under $250,000") &&
              (Request.Form(" Organization") == "1")) {
              MyVarMailto = "email1@zoomint ernet.net";
              }
              else if ((Request.Form( "LoanReques t") == "Over $250,000") &&
              (Request.Form(" Organization") == "1")) {
              MyVarMailto = "email2@fpfc.ne t";
              }
              else {
              MyVarMailto = "email3@gmail.c om";
              >
              And also this:
              >
              var MyVarMailto = "email1@fpfc.ne t";
              var MyAmt = Request.Form("L oanRequest");
              var MyOrg = Request.Form("O rganization");
              >
              if (MyOrg == "1") {
              if (MyAmt == "1") {
              MyVarMailto = "email2@zoomint ernet.net";
              } else if (MyAmt == "2") {
              MyVarMailto = "email3@gmail.c om";
              }
              }
              >
              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.


              Comment

              • tbird2340@gmail.com

                #8
                Re: If / Then / Else Help Needed - More then one condition possible?

                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

                Comment

                • tbird2340@gmail.com

                  #9
                  Re: If / Then / Else Help Needed - More then one condition possible?

                  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.
                  >
                  >
                  --

                  Comment

                  • McKirahan

                    #10
                    Re: If / Then / Else Help Needed - More then one condition possible?

                    <tbird2340@gmai l.comwrote in message
                    news:1158764914 .442442.38970@m 7g2000cwm.googl egroups.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.


                    Comment

                    • tbird2340@gmail.com

                      #11
                      Re: If / Then / Else Help Needed - More then one condition possible?

                      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...

                      Comment

                      • McKirahan

                        #12
                        Re: If / Then / Else Help Needed - More then one condition possible?

                        <tbird2340@gmai l.comwrote in message
                        news:1158769610 .637879.227430@ m7g2000cwm.goog legroups.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("BFSLoan_ Referral@fpfc.n et",MyVarMailto ,"BFS Loan Referral",MyVar Body)

                        // CDO_Code.asp
                        function email(eFrom,eTo ,eSubj,eBody)
                        var cdomail;
                        cdomail = Server.CreateOb ject("cdonts.ne wmail");
                        cdomail.from = eFrom;
                        cdomail.to = eTo;
                        cdomail.subject = eSubj;
                        cdomail.body = eBody;
                        cdomail.MailFor mat = 0;
                        cdomail.BodyFor mat = 0;
                        cdomail.send();
                        }

                        Prepare a standalone page to test it:

                        <% @Language="JScr ipt" %>
                        <!--#include file="CDO_Code. asp"-->
                        <html>
                        <head>
                        <title>CDO_Test .asp</title>
                        <% var eFrom = "BFSLoan_Referr al@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="LoanReque st" 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.)


                        Comment

                        • tbird2340@gmail.com

                          #13
                          Re: If / Then / Else Help Needed - More then one condition possible?

                          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?

                          Comment

                          • McKirahan

                            #14
                            Re: If / Then / Else Help Needed - More then one condition possible?

                            <tbird2340@gmai l.comwrote in message
                            news:1158779297 .218067.316630@ d34g2000cwd.goo glegroups.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.


                            Comment

                            • tbird2340@gmail.com

                              #15
                              Re: If / Then / Else Help Needed - More then one condition possible?

                              Ok. Thanks for the help.

                              Comment

                              Working...