Need a little help with this please

Need a little help with this please

AmbientAmbient Posts: 23Questions: 9Answers: 0
edited October 2020 in Free community support

Trying to get this email button to work but getting an error.

https://datatables.net/forums/discussion/21982/is-there-a-way-to-email-a-datatable

I'm new to all this and I'm guessing it's something to do with this

var pid = $("#elempid").val();

To what does that refer?

And where should I put that reference. The sendmail is triggering fine. My code is same except table reference.

Console output below.

 <table>
            <thead>
                <tr role=\"row\"><th class=\"sorting\" tabindex=\"0\" aria-controls=\"pexpenses\" rowspan=\"1\" colspan=\"1\" aria-label=\"Type: activate to sort column ascending\" style=\"width: 235px;\">Type</th><th class=\"sorting_asc\" tabindex=\"0\" aria-controls=\"pexpenses\" rowspan=\"1\" colspan=\"1\" aria-label=\"Description: activate to sort column ascending\" style=\"width: 425px;\" aria-sort=\"ascending\">Description</th><th class=\"sorting\" tabindex=\"0\" aria-controls=\"pexpenses\" rowspan=\"1\" colspan=\"1\" aria-label=\"Cost: activate to sort column ascending\" style=\"width: 152px;\">Cost</th><th class=\"sorting\" tabindex=\"0\" aria-controls=\"pexpenses\" rowspan=\"1\" colspan=\"1\" aria-label=\"Quantity: activate to sort column ascending\" style=\"width: 239px;\">Quantity</th><th class=\"sorting\" tabindex=\"0\" aria-controls=\"pexpenses\" rowspan=\"1\" colspan=\"1\" aria-label=\"Item Total: activate to sort column ascending\" style=\"width: 274px;\">Item Total</th></tr>
            <thead>

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    To what does that refer?

    There would be an input element on that page, and that's just getting the value of it.

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • AmbientAmbient Posts: 23Questions: 9Answers: 0

    Thank You Colin! Completely stuck with this!

    http://live.datatables.net/nafahopu/1/edit

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
            var data = table.row( this ).data();
    

    You don't have a variable called "table". Your DataTable object is not assigned to any variable.

    $('#giftcards').DataTable(
    
  • AmbientAmbient Posts: 23Questions: 9Answers: 0

    Yes thank you, but that is for the drill down I'm trying to implement.

    var data = table.row( this ).data();
    nothing to do with the email.

  • kthorngrenkthorngren Posts: 21,470Questions: 26Answers: 4,977

    Completely stuck with this!

    Please describe what you are expecting to happen. Your post form data looks like this:

    PID: Just a test
    emailbody: <td class="sorting_1">   Ally Bally</td><td>   79 Rathgale</td><td>   </td><td>   The Tridge</td><td>   BT99 3PY</td><td>   </td>,<td class="sorting_1">   Colin Black</td><td>   60 Carney Drive</td><td>   </td><td>   Nowhere</td><td>   BT345 1FB</td><td>   </td>,<td class="sorting_1">   George Carnahan</td><td>   46 Mount</td><td>   Dunmurry</td><td>   Belfast</td><td>   BT99 9TD</td><td>   </td>,<td class="sorting_1">  Jack  O'neill</td><td>   87 Corse Road</td><td>   Somewhere</td><td>   ccct</td><td>   BT145 7NA</td><td>   </td>,<td class="sorting_1">   Larruu Murphy</td><td>   78 Kern Hill Manor</td><td>   Portvale</td><td>   </td><td>   BT102 XYR</td><td>   </td>,<td class="sorting_1">   Mr Mouse</td><td>   34 Glenmore Place</td><td>   </td><td>   </td><td>   BT78 XQT</td><td>   </td>
    emailfoot: <span> Date Range Executed :2020
    

    Please lot us know what you want sent.

    Kevin

  • AmbientAmbient Posts: 23Questions: 9Answers: 0

    I am trying to send an email with the datatable data in it. I'm using the sendmail function. It is dropping into This

    alert("Email Error! Please check browser console by pressing CTRL + SHIFT + I !");

  • kthorngrenkthorngren Posts: 21,470Questions: 26Answers: 4,977

    So you are saying that the if(data == "okay"){ statement is false so the alert massage is displayed in the below code:

        $.ajax({
            url: "sendemail.php",
            type: "POST",
            data: "PID=" + pid + "&emailbody=" + rowStr + "&emailfoot=" + footer,
            success:function(data){
                if(data == "okay"){
                    alert("Email has been sent!");
                }
                else{
                    console.log(dt,data);
                    alert("Email Error! Please check browser console by pressing CTRL + SHIFT + I !");
                    console.log("Error Data Received:" + data);
                }
            }
    

    This is not a Datatables issue. You will need to debug the sendmail.php script to find out what is happening and why data does not equal okay.

    Kevin

This discussion has been closed.