A
A
Andrey2019-12-02 19:33:07
JavaScript
Andrey, 2019-12-02 19:33:07

How to pass a variable from js to Mod X Evo to send it to mail in FormIt?

The site on ModX Evo has a calculator in JS, here is a snippet of its code

$(".calc .more").click(function(e){
    var title = "Расчет стоимости обслуживания";
    
    
    //Форма налогообложения
    var _nalog = $(".calc input[name=nalog]:checked").val();
    //Род деятельности
    var _occupation = $(".calc input[name=occupation]:checked").val();
    //Документов в месяц
    var _docs = $(".calc input[name=docs]").val();
    //Сотрудиков
    var _personal = $(".calc input[name=personal]").val();
    
    if(_docs=="1") _docs_txt="до 20";
    if(_docs=="2") _docs_txt="20-40";
    if(_docs=="3") _docs_txt="40-60";
    if(_docs=="4") _docs_txt="60-100";
    if(_docs=="5") _docs_txt="100-150";
    if(_docs=="6") _docs_txt="от 150";
    
    if(_nalog=="1") _nalog_txt="УСН,доходы(6%)";
    if(_nalog=="2") _nalog_txt="УСН,доходы-расходы(15%)";
    if(_nalog=="3") _nalog_txt="ОСН,НДС(18%,10%,0%)";
    
    if(_occupation=="1") _occupation_txt="Услуги";
    if(_occupation=="2") _occupation_txt="Торговля";
    if(_occupation=="3") _occupation_txt="Производство";
    if(_occupation=="4") _occupation_txt="Строительство";
    
    var note = "\nФорма налогообложения: "+_nalog_txt+"\nРод деятельност: "+_occupation_txt+" \nКол-во документов: "+_docs_txt+" \nСотрудников: " + _personal + "\nПодсчитанная стоимость: " + $(".calc-total div").text();
    
    $(".form-order input[name=type]").val("calc");
    showOrderForm(title,  note); 
    
    e.preventDefault();
  });

Its result is written to the "note" variable. The question is how to pass it to FormIt to send it to the mail along with the rest of the data?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2019-12-03
@WebAnalitikINFO

Maybe some other information needs to be provided?

S
Sagrana, 2019-12-03
@sagrana

As far as I know, FormIt is a snippet for MODX Revolution, not Evolution.
But, in general, you need to add some hidden input to the form that you submit and write the value of your variable to it with the result of the calculator.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question