Should be easy - Variable to email?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Larry L

    #1

    Should be easy - Variable to email?

    This is a novice question, but I'm stumped. I have a variable with a bunch
    of text assigned to it. Now I want to email the value of the variable. I
    have a simple form that asks for their name and emails that, but how do I
    add the variable result?

    Thanks much,
    Larry
  • kaeli

    #2
    Re: Should be easy - Variable to email?

    In article <vurdd.18757$jo 2.16341@twister .socal.rr.com>,
    larry@somewhere inhawaii.com enlightened us with...[color=blue]
    > This is a novice question, but I'm stumped. I have a variable with a bunch
    > of text assigned to it. Now I want to email the value of the variable. I
    > have a simple form that asks for their name and emails that, but how do I
    > add the variable result?
    >[/color]

    If you are mailing server-side, as is most stable and robust for internet
    applications, you do it with the server-side language of choice.

    If you are using mailto as a form action, it's not good for this. You would
    basically have to have a javascript handler for the form that writes the
    value of the variable to a hidden form field and then submits the form, then
    when the form is mailed, you'll get the value in there. Obviously it wouldn't
    work for users without script.

    There are a lot of possible problems with using mailto for internet apps, so
    if you are, you might want to look in the archives and decide if it's really
    want you want to use.

    --
    --
    ~kaeli~
    Synonym: the word you use in place of a word you can't
    spell.



    Comment

    • Grant Wagner

      #3
      Re: Should be easy - Variable to email?

      Larry L wrote:
      [color=blue]
      > This is a novice question, but I'm stumped. I have a variable with a bunch
      > of text assigned to it. Now I want to email the value of the variable. I
      > have a simple form that asks for their name and emails that, but how do I
      > add the variable result?
      >
      > Thanks much,
      > Larry[/color]

      <form method="POST" action="sendmai l.cgi">
      <script type="text/javascript">
      document.write( '<input type="hidden" name="stuff" value="' + yourVariable +
      '">');
      </script>
      <input type="submit" value="Send Stuff">
      </form>

      If yourVariable may contain quotation marks or new line characters, you must
      either remove them, replace them, or escape them.

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

      Comment

      • Larry L

        #4
        Re: Should be easy - Variable to email?

        In article <4176A070.ACCD0 434@agricoreuni ted.com>, Grant Wagner <gwagner@agrico reunited.com> wrote:[color=blue]
        >Larry L wrote:
        >[color=green]
        >> This is a novice question, but I'm stumped. I have a variable with a bunch
        >> of text assigned to it. Now I want to email the value of the variable. I
        >> have a simple form that asks for their name and emails that, but how do I
        >> add the variable result?
        >>
        >> Thanks much,
        >> Larry[/color]
        >
        ><form method="POST" action="sendmai l.cgi">
        ><script type="text/javascript">
        >document.write ('<input type="hidden" name="stuff" value="' + yourVariable +
        >'">');
        ></script>
        ><input type="submit" value="Send Stuff">
        ></form>
        >
        >If yourVariable may contain quotation marks or new line characters, you must
        >either remove them, replace them, or escape them.
        >[/color]

        Grant,

        Well it took me this long to understand what is happening in my page. Your
        script, of course, works perfectly by itself. However, on my page I do
        several things, requiring user input, to create the variable that I then
        want to send via formmail. As I understand it, your code executes as the
        page loads, and at that point the variable is empty. I have a form
        that runs some other javascript that creates the value (a string) in the
        variable, then I have a simple second form with a button you click to
        display it, then a third form that asks for yor name, and sends the
        name and string via email. The first 2 are working. Any further
        suggestions for the 3rd?

        Thanks much,
        Larry

        Comment

        Working...