The question is regarding PHP and Javascript/Jquery.

I have a php page which process the form data and displays it on SUBMIT.
I need to collect that data into javascript.
how should I proceed?

//Php file

$uname = $_SESSION['sessionVar'];

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Selected Details for E-mail</title>

// To pop-up the outlook & send the mail

<script type = "text/javascript" src = "script/mail.js"></script>
  <script type="text/javascript">
    $(function () {
      $('.btnSendEmail').click(function (event) {
        var email = 'sendermail@email.com';
        var subject = 'sender Subject';
        var emailBody = 'body'; 

//here in EmailBody I want to print the data collected from the page

        window.location = 'mailto:' + email + '?subject=' + subject + '&body=' + emailBody;

<body bgcolor = #B0D1F3>
<br /><br/>
User <b><?php echo $uname;?></b>  has requested to refresh  <b><?php echo $_POST["name"]; ?></b> with  <?php 
if(!empty($_POST["list"])) {
$snapname = $_POST['list'];
echo "snapname :<b> ".$list." </b><br/>";
else {
echo "<b>Please Select the list items.</b>";

With following Commands:
if(!empty($_POST['instance'])) {
$checked_count = count($_POST['instance']); // Counting number of checked checkboxes.
echo "(You have selected following) <b>".$checked_count."</b> option(s): <br/>"; // Loop to store and display values of individual checked checkbox.
foreach($_POST['instance'] as $selected) {
echo "<p><b>".$selected ."</b></p>" ; 
echo "<b>Please Select Atleast One Option.</b>";

    <INPUT Type="button" VALUE="Back" onClick="history.go(-1);return true;"> 
    <button class="btnSendEmail">Send Email</button><br /><br /> 

// on click of Send Email button, it gives me the outlook and body should contain the data on that page which is processed from prvious page


Recommended Answers

All 2 Replies

I guess you could Jquery width AJAX to collect details of your form data.
I couldn't understand your question well;

You could do something like:

 var submit = $(this).val();

You need to create a span page to display the data

Are you sending the user to another URL or the same page? If not, you need to add the Javascript in your button "onclick" event and add Ajax part of Javascript. If you want to use the current script (which seems to show that you want to send data to the same page), you must add "form" tag and set the target action to the same page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.