Welcome to DirectSmile

Delete record - how to show confirmation page ?

link this post written on 16/08/2013
  • To top

Hi,

I have a campaign with a data-relation. One personal page shows a data table with every leads.

In this table, I added a button to edit parameters of each leads. It works perfectly !

Now, I want to add a system to delete the selected lead. The "delete record" item works but the problem is we don't have any confirmation page like "Are you sure to delete this record ?". I tried a lot of method with cookies, new data-relation, but i don't solve my problem....

Have you a solution for me ?

link this post written on 19/08/2013
  • To top

Hi,

This can be achieved by adding some jQuery and javascript like below.

 

  1. Check the id of "Delete Record" button.
  2. Adding jQuery which replace onclick function to confirm window and set post action to exact function which set was default.

 

So it should looks like below.

 

<script type="text/javascript" >
$(document).ready(function() {
    var rDArray = new Array();
    for (var i=0; i<$("[id=Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]").length; i++) {
    tmp = $("[id=Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]").eq(i).attr("onclick");
    var tmp2 = tmp.split("'")
    var tmp3 = tmp2[3];
    rDArray[i]    = tmp3;
    $("[id=Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]").eq(i).removeAttr("onclick");
    $("[id=Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]").eq(i).attr("onclick", "disp("+ rDArray[i] +")");
    }
    });
   
    function disp(rdNum){
        if(window.confirm('Are you sure to delet this record?')){
        dsmf_SubmitWithContext('Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', rdNum)
        }
        else{
            window.alert('Cancelled');
        }
    }
</script>

 

I hope it will help you

 

Best regards,

NOG

The author has edited this post (on 19/08/2013)
link this post written on 19/08/2013
  • To top

Hi,

Ok, Thank you very much for this fast and technical answer !

I will try your script. I think, I understood the way.

I have already said it but I repeat it: it is a real pleasure to feel helped like that !

 

This tip can maybe help other users ...

 

link this post written on 19/08/2013
  • To top
It works marvelously !

I can easily personalize the text of alert window, I even managed to place a variable with [[]] (the name of user which is connected to the admin - it's a value of the database of the campaign). But I don't manage to place a variable corresponding to the current recording of my table (data relation). The result is : "No data rows".

How may I make reference to the current and selected recording (= line of my table whose button was clicked) in the script?

link this post written on 20/08/2013
  • To top

Hi,

It's good to hear Seems the variable you called doesn't match with filter condition. I guess that is the reason why you are getting "No Data Rows" as value. Since it is very specific question, I recommend you to visit DirectSmile Support Center, and ask solution for your demand.

 

It always very helpful if you can provide all necessary detail descritption of your current situation and configuration, and demand itself to Support Team.

 

Best regards,

NOG

link this post written on 26/11/2013
  • To top
Hi Nog,

Thank you for your script and for your excellent work! (Also all the DirectSmile Team)

Kind regards
Jaume
link this post written on 27/11/2013
  • To top

I'd be honoured if my tip could help you

You are welcome!

 

NOG

link this post written on 24/07/2015
  • To top

Hi,

I have a problem with the script presented.

<script type="text/javascript" >
$(document).ready(function() {
    var rDArray = new Array();
    for (var i=0; i<$("[id=Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]").length; i++) {
    tmp = $("[id=Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]").eq(i).attr("onclick");
    var tmp2 = tmp.split("'")
    var tmp3 = tmp2[3];
    rDArray[i]    = tmp3;
    $("[id=Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]").eq(i).removeAttr("onclick");
    $("[id=Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]").eq(i).attr("onclick", "disp("+ rDArray[i] +")");
    }
    });

function disp(rdNum){
        if(window.confirm('Are you sure to delet this record?')){
        dsmf_SubmitWithContext('Relations_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', rdNum)
        }
        else{
            window.alert('Cancelled');

------------------------

I have replaced all "relations_xxxx" with the id of the my data list.

When I try to use the script and I want to delete the record in the data list, I receive an error message which indicates that the variable "rdNum" is "undefined" and the the record is not deleted.

What did I miss?

Is there a error inthe script?

Thanks for your reply.

link this post written on 28/07/2015
  • To top

Hi,

It still works fine with Ver6.1 DSMX. So I assume you may have some kind of break in the scripting part.

Could you please double check that? Maybe if you check your campaign page on FireFox with Firebug, it will help you to identify whether it has any issue or not.

 

Best regards,

NOG

link this post written on 29/07/2015
  • To top

Hi, 

This is a copy of my script, I just changed "Relations_ xxx" by the id of the delete button :

 

<script type="text/javascript" >

$(document).ready(function() {

    var rDArray = new Array();

    for (var i=0; i<$("[id=PURL2_a2f2530d24a9f4c008523227aba67ed31]").length; i++) {

    tmp = $("[id=PURL2_a2f2530d24a9f4c008523227aba67ed31]").eq(i).attr("onclick");

    var tmp2 = tmp.split("'")

    var tmp3 = tmp2[3];

    rDArray[i]    = tmp3;

    $("[id=PURL2_a2f2530d24a9f4c008523227aba67ed31]").eq(i).removeAttr("onclick");

    $("[id=PURL2_a2f2530d24a9f4c008523227aba67ed31]").eq(i).attr("onclick", "disp("+ rDArray[i] +")");

    }

    });

 

    function disp(rdNum){

        if(window.confirm('Are you sure to delet this record?')){

        dsmf_SubmitWithContext('PURL2_a2f2530d24a9f4c008523227aba67ed31', rdNum)

        }

        else{

            window.alert('Cancelled'); 

        }

    }

</script>

 

And this is the message a get when I validate the confirmation message :

 

Any idea?

 

Best Regards,

Caroline.

 

  • Statistics: 11 Posts | 92 Visits
created by mixxt
  • v1.1.1
  • (highfive)