0

Hi,
I have php page, 2.php, which collects the data and dispalys it from previous page , 1.php.

In 2.php, I also have html and javaScript, which contains a button, and cerresponding onclick script, which opens the OUTLOOk to send the E-mail with given sendername and subject.

But for body part of the mail, I want to fetch the details displayed in 2.php and print it using JavScript.

//My <script>

<script type = "text/javascript" src = "script/mail.js"></script>
  <script type="text/javascript">
    $(function () {
      $('.btnSendEmail').click(function (event) {
        var email = 'senderemail@email.com';
        var subject = 'Hello!!';
        var emailBody = 'need to fetch the data and print it here';
        window.location = 'mailto:' + email + '?subject=' + subject + '&body=' + emailBody;
      });
    });
  </script>

Edited by Azii: Added code Snippet

2
Contributors
1
Reply
19
Views
2 Years
Discussion Span
Last Post by broj1
1

In 2.php you should have details enclosed within an html eement (such as div) with an ID so that you can access it using jquery text() or html() or similar method.

<div id="my-content">
This is the body of the email.
</div>

var emailBody = $("#my-content").text();

Edited by broj1

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.