Sending email by button

Asked

Viewed 68 times

0

At the stage I need to maintain and develop the system they use, however, I am the only one in the IT sector and I do not have information exchange, as well. This function below when changing a specific field it asks if you want to notify the changes via E-mail, with a specific email(flTipo=NDVG,flTipo=NDCA,flTipo=NDRA) for each field type(VGM,LOAD,DRAFT). I needed to apply this way of sending email to a button, just this, I have manipulated the code and performed testing in various ways and have not succeeded.

Thank you if you can help me!

function alterarDeadLines(ID_CD_BOOKING,flTipoBL,flTipo){
    $('#formBooking'+ID_CD_BOOKING).find("#acao").val('UDT');   

    $('#formBooking'+ID_CD_BOOKING).find("#flTipo").val(flTipo);
    $('#formBooking'+ID_CD_BOOKING).find("#flTipoBL").val(flTipoBL);

    $('#formBooking'+ID_CD_BOOKING).submit()    

    if( flTipo == "VGM" ){ 

        $("#dialog-confirm").attr("title","Notificar alterações<i class='icon-help'></i>");
        $("#dialog-confirm").find("p").html("Deseja notificar por e-mail as altera&ccedil;&otilde;es realizadas?<br><br>");
        $( "#dialog-confirm" ).dialog({
            resizable: false,   modal: true,
            width: 500,         height:300,             
            buttons: {
                "Não desejo": function() {
                    $(this).dialog("close");
                },
                "Notificar alterações": function() {
                    $('#formBooking'+ID_CD_BOOKING).find("#flTipo").val("NDVG"); 
                    $('#formBooking'+ID_CD_BOOKING).find("#flTipoBL").val("");

                    dataString  = $("#formBooking"+ID_CD_BOOKING).serialize();   
                    $("#btnBoxDefaultAjax").attr('href','anexos-form.asp?'+dataString).click();  
                    $(this).dialog("close");                        
                }
            }
        }); 
    }else if( flTipo == "Carga" ){ 

        $("#dialog-confirm").attr("title","Notificar alterações<i class='icon-help'></i>");
        $("#dialog-confirm").find("p").html("Deseja notificar por e-mail as altera&ccedil;&otilde;es realizadas?<br><br>");
        $( "#dialog-confirm" ).dialog({
            resizable: false,   modal: true,
            width: 500,         height:300,             
            buttons: {
                "Não desejo": function() {
                    $(this).dialog("close");
                },
                "Notificar alterações": function() {
                    $('#formBooking'+ID_CD_BOOKING).find("#flTipo").val("NDCA"); 
                    $('#formBooking'+ID_CD_BOOKING).find("#flTipoBL").val("");

                    dataString  = $("#formBooking"+ID_CD_BOOKING).serialize();   
                    $("#btnBoxDefaultAjax").attr('href','anexos-form.asp?'+dataString).click();  
                    $(this).dialog("close");                        
                }
            }
        }); 
    }else if( flTipo == "Draft" ){ 

        $("#dialog-confirm").attr("title","Notificar alterações<i class='icon-help'></i>");
        $("#dialog-confirm").find("p").html("Deseja notificar por e-mail as altera&ccedil;&otilde;es realizadas?<br><br>");
        $( "#dialog-confirm" ).dialog({
            resizable: false,   modal: true,
            width: 500,         height:300,             
            buttons: {
                "Não desejo": function() {
                    $(this).dialog("close");
                },
                "Notificar alterações": function() {
                    $('#formBooking'+ID_CD_BOOKING).find("#flTipo").val("NDRA"); 
                    $('#formBooking'+ID_CD_BOOKING).find("#flTipoBL").val("");

                    dataString  = $("#formBooking"+ID_CD_BOOKING).serialize();   
                    $("#btnBoxDefaultAjax").attr('href','anexos-form.asp?'+dataString).click();  
                    $(this).dialog("close");                        
                }
            }
        }); 
    }   
}
  • 1

    Well, look at this: $('#formBooking'+ID_CD_BOOKING).find("#flTipo")... Makes no sense fetch an element by id, since an id should if only on the page. It should be: $("#flTipo")... then only then does your HTML already have problems.

  • You should only use .find() to search for a descendant by class, tag name, attribute etc., never by id. It even works because you will force an id to fetch another id descending, but it is wrong by HTML specifications to repeat id.

  • You already have the code ASP, I assume your backend is ASP on account $("#btnBoxDefaultAjax").attr('href','anexos-form.asp?'+dataString).click();, to generate the email? If you have already put the code in the question, also put the html because we need to know what will be serialized $("#formBooking"+ID_CD_BOOKING).serialize()

  • I do have @Augustovasques but only the attachment-form.Asp has more than 800 lines, is there a way for me to attach the file? And what does serialize do? Turns the object into a concatenated string ?

  • Put the relevant parts, the endpoints that are used in this code. As for the serialize

  • I understood the Serialize @Augustovasques thank you. About the code, I thought it best to leave it complete so that you could read better. https://jsfiddle.net/nof6dpme/ I left this jsfiddle in the html section. Thank you for your attention, man.

  • The night and take a slow look.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.