Help with JavaScript CDONTS code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cmcvicker@nfda-fastener.org

    Help with JavaScript CDONTS code

    I have the following code in an ASP webpage where a member has logged
    in and wants to change his company information. This page lists the
    fields and records currently in our database (Access) and he is able to
    make changes and submit it. My code updates the database fine and
    redirects them to another page fine.

    Now I want that information emailed to me as well. I have found code
    and spent hours tweeking it to work and I finally get NO errors. The
    only problem is that when I receive the e-mail, all of the fields say
    undefined instead of the actual record. For instance:

    THIS IS THE EMAIL:

    Company: undefined
    Division: undefined
    Mailing Address: undefined



    THIS IS THE CODE:

    <%

    var objCDO = Server.CreateOb ject("CDONTS.Ne wMail");


    objCDO.From = "webmaster@...o rg"
    objCDO.To = "me@...org"
    objCDO.Subject = "Member Company Updated!"
    objCDO.Body = "The following member company information has been
    updated." + "\n\n"
    + "Company: " + Request.Form("M brCompany") + "\n"
    + "Division: " + Request.Form("e mail") + "\n"
    + "Mailing Address: " + Request.Form("M brMailingAddres s") + "\n"
    + "Mailing City, State, Zip: " + Request.Form("M brMailingCity") + " "
    + Request.Form("M brMailingState" ) + " " + Request.Form("M brMailingZip")
    + "\n\n"
    + "Shipping Address: " + Request.Form("M brShippingAddre ss") + "\n"
    + "Shipping City, State, Zip: " + Request.Form("M brShippingCity" ) + "
    " + Request.Form("M brShippingState ") + " " +
    Request.Form("M brShippingZip") + "\n\n"
    + "Phone: " + Request.Form("M brMainPhone") + "\n"
    + "Alt Phone: " + Request.Form("M brAltPhone") + "\n"
    + "Fax: " + Request.Form("M brMbrFax") + "\n"
    + "Intl Phone: " + Request.Form("M brPhoneIntl") + "\n"
    + "Intl Fax: " + Request.Form("M brFaxIntl") + "\n"
    + "Email: " + Request.Form("M brEmail") + "\n"
    + "Website: " + Request.Form("M brWebsite") + "\n\n"
    + "Please file this in the member's folder."
    objCDO.BodyForm at = 1
    objCDO.MailForm at = 1
    objCDO.Send()
    objCDO = null

    %>

    Any help????

  • Martin Honnen

    #2
    Re: Help with JavaScript CDONTS code



    cmcvicker@nfda-fastener.org wrote:
    [color=blue]
    > I have the following code in an ASP webpage where a member has logged
    > in and wants to change his company information. This page lists the
    > fields and records currently in our database (Access) and he is able to
    > make changes and submit it. My code updates the database fine and
    > redirects them to another page fine.
    >
    > Now I want that information emailed to me as well. I have found code
    > and spent hours tweeking it to work and I finally get NO errors. The
    > only problem is that when I receive the e-mail, all of the fields say
    > undefined instead of the actual record. For instance:
    >
    > THIS IS THE EMAIL:
    >
    > Company: undefined[/color]
    [color=blue]
    > objCDO.Body = "The following member company information has been
    > updated." + "\n\n"
    > + "Company: " + Request.Form("M brCompany") + "\n"[/color]

    Well if it says undefined then in the ASP page with that code
    Request.Form("M brCompany") yields undefined. As you say that you
    redirect then the problem is probably simply that HTTP POST information
    is not transferred when redirecting thus any attempt in ASP to read
    Request.Form("a rgname") will give you undefined.
    Or that ASP page receives the data in the query string part of the URL
    and then
    Request.QuerySt ring("MbrCompan y")
    is the proper way to extract the data.

    --

    Martin Honnen

    Comment

    • ConnieM

      #3
      Re: Help with JavaScript CDONTS code

      Thanks for the response Martin. I tried replacing the Request.Form with
      Request.QuerySt ring, but it still gives me undefined values in the
      email. Any other suggestions?

      Comment

      • Martin Honnen

        #4
        Re: Help with JavaScript CDONTS code



        ConnieM wrote:
        [color=blue]
        > I tried replacing the Request.Form with
        > Request.QuerySt ring, but it still gives me undefined values in the
        > email. Any other suggestions?[/color]

        For a start don't bother with emailing stuff but find out first how data
        is passed to the page, if no data is passed to the page in the query
        string then Request.QuerySt ring can't give you any data in the ASP page.
        All you are doing is building a string e.g.

        "The following member company information has been
        updated." + "\n\n"
        + "Company: " + Request.Form("M brCompany") + "\n"
        + "Division: " + Request.Form("e mail") + "\n"

        or now

        "The following member company information has been
        updated." + "\n\n"
        + "Company: " + Request.QuerySt ring("MbrCompan y") + "\n"
        + "Division: " + Request.QuerySt ring("email") + "\n"

        obviously in ASP those Request properties do only reflect what is passed
        to the page thus if you get undefined then nothing has been passed to
        the page.

        So you need to look at how data is passed to the page, to have data in
        the query string you for instance would need a link alike
        <a href="http://example.com/mail.asp?MbrCom pany=company&em ail=whoever">
        the ASP will have values for
        Request.QuerySt ring("MbrCompan y")
        and
        Request.QuerySt ring("email")

        --

        Martin Honnen

        Comment

        • Grant Wagner

          #5
          Re: Help with JavaScript CDONTS code

          "ConnieM" <cmcvicker@nf da-fastener.org> wrote in message
          news:1105733661 .719269.298090@ z14g2000cwz.goo glegroups.com.. .[color=blue]
          > Thanks for the response Martin. I tried replacing the Request.Form
          > with
          > Request.QuerySt ring, but it still gives me undefined values in the
          > email. Any other suggestions?[/color]

          As Martin has already suggested, you mention that you "redirect to
          another page" after processing the form. This will result in "throwing
          away" all the values of the Request.QuerySt ring() and Request.Form()
          collections.

          A redirect simply tells the browser to do a GET on the new URL, anything
          in the POST buffer (or originally passed to <FORM
          ACTION="yourFor mHandler.asp?So mething=Whateve r">) is lost when the
          browser requests the new page.

          If you actually want to pass data from the page that handles <FORM
          ACTION="..."> to a new page, you have two options:

          1) store the values of the form in the Session object and retrieve them
          on the new page (I don't recommend this)
          2) take the values obtained from Request.Form(), write script to build a
          query string containing the information you want and pass it to the
          redirect page as part of the redirect.

          So, on the page that handles <FORM ACTION="...">

          <%
          var CompanyNameVar = Request.Form('C ompanyName');
          var BlahBlahVar = Request.Form('B lahBlah');
          var SomethingElseVa r = Request.Form('S omethingElse');

          // update the database and do whatever

          Response.Redire ct(
          "SendEmail.asp? " +
          "CompanyNam e=" +
          Server.URLencod e(CompanyNameVa r) +
          "&BlahBlah= " +
          Server.URLencod e(BlahBlahVar)) ;
          %>

          NOW the values of CompanyName, BlahBlah (but NOT SomethingElse) will be
          accessible to SendEmail.asp using Request.QuerySt ring(). If you want
          SomethingElse too, _you_ have to include it on the query string passed
          to SendEmail.asp.

          Of course, if you try to pass large (> 512 bytes) of information this
          way, you run the risk that the browser won't pass the entire query
          string correctly, resulting in lost data.

          --
          Grant Wagner <gwagner@agrico reunited.com>
          comp.lang.javas cript FAQ - http://jibbering.com/faq


          Comment

          Working...