ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Embed email into submit.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Embed email into submit.

    Hello Guys,

    Is it possible to embed an email address and mail all the information in the form into the submit button.

    I mean when the user fills up the form and hits submit all the values in he form will be mailed to an email address specified within the form itself.

    Is it possible. Please reply and let me know.

    Regards,

    Nash.

  • #2
    Re: Embed email into submit.

    Yes this is possible
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Embed email into submit.

      What is the Client language used ?
      Philippe

      Comment


      • #4
        Re: Embed email into submit.

        Javascript Use an HTML Form to Call the User's E-mail Application

        Although you can process e-mail addresses using server-side code,
        sometimes it is easier to let your server-side code set up the original parameters
        for the e-mail and then just let the user's own e-mail application handle the rest.

        Here's a method to get the process started from within an HTML form:

        Code:
        <HTML>
        <HEAD>
        <script language="javascript">
        function dosub() {
        location.href='mailto:' + document.forms[0].text1.value + '?subject=' +
        document.forms[0].text2.value
        }
        </script>
        </HEAD>
        <BODY>
        <FORM action="" id=form1 method=post name=form1>
        Email address: <INPUT id=text1 name=text1 value='yourname@internet.com' ><br>
        Subject:  <INPUT id=text2 name=text2 value='Embed email Tip' > <br>
        <INPUT type=button onclick="dosub();" value=" OK ">
        </FORM>
        </BODY>
        </HTML>

        Comment


        • #5
          Re: Embed email into submit.

          I thought you had to include an enctype of text/plain so decided to have a little go. I found it fired up an outlook window to send the email with the correct subject but you couldn't see any other data from the form.

          PHP Code:
          <html>
          <
          head>
          <
          script type="text/javascript" language="JavaScript">
          function 
          dosub() {
          var 
          form1 document.getElementById('form1');
          var 
          action "mailto:" document.getElementById("text1").value '?subject=' +
          document.getElementById("text2").value;
          form1.action action;
          form1.submit();
          }
          </
          script>
          </
          head>
          <
          body>
          <
          form action="" id="form1" method="post" name="form1" enctype="text/plain">
          <
          label for="text1">Email Address: </label><input id="text1" name="text1" value="yourname@internet.com" ><br />
          <
          label for="text2">Subject: </label><input id="text2" name="text2" value="embed email tip" > <br />
          <
          label for="text3">Random Field: </label><input id="text3" name="text3" value="some text" > <br />
          <
          input type="button" onclick="dosub();" value=" ok ">
          </
          form>
          </
          body>
          </
          html
          Note I put the JavaScript onto separate lines with variables so you can step it through in firebug. If preferred this could be condensed to just two lines of JavaScript. I also lowercase'd all html elements and surrounded all attributes with double quotes as is required by an XHTML validator. Also, all elements should have a closing element so <br> should be <br />. You can get away with things like this in HTML because most browsers cope with syntax misdemeanour's but it's a good habit to get into. You certainly can't complain about IE not following the standards unless you attempt to follow them yourself.
          Ben

          Comment


          • #6
            Re: Embed email into submit.

            There are 100's of examples of javascript e-mail forms !
            Google !

            Comment


            • #7
              Re: Embed email into submit.

              Thanks for replying guys

              I have an index.html file that contains the form and a dbconnect.jsp where do I insert the code ....Does it have to be in the dbconnect or the index?

              Regards,

              Nash

              Comment

              Working...
              X