There is such a form with javascriptom
<script> $(document).ready(function(){ $('.calc select').change(function(){ $country = $('select#choose-country').val(); if ($country == 'austria') { $koef = 1; } if ($country == 'great-britain') { $koef = 2; } if ($country == 'nederland') { $koef = 3; } $totalprice = $koef * 100; $('#price').text($totalprice); }) </script> <section id="main"> <form method="post" id="ajax_form" action="" > <select class="form-control" name="country" id="choose-country"> <option value="austria">Австрия</option> <option value="great-britain">Великобритания</option> <option value="nederland">Голландия</option> </select> <div class="price-final"> <h5>Цена зависит от страны</h5> <span name="price" id="price">0</span>EUR</div> <button id="calc-price" type="button" class="btn-warning">Посчитать</button> <button id="send-price-to-us" type="submit" class="btn-success">Выслать нам заявку</button> </form> </section> After that I send the data using Ajax like this
<script src="https://какой-то.сайт/calc-price/email.js"></script> $(document).ready(function() { $("#ajax_form").submit(function() { $.ajax({ type: "POST", url: "/calc-price/e-mail-form/send-form1.php", data: $(this).serialize() }).done(function() { $(this).find("input, span").val(""); alert("Спасибо за заявку! Скоро мы с вами свяжемся."); $("#ajax_form").trigger("reset"); }); return false; }); }); Further the class code for sending an email looks like this
<?php $recepient = "myemail@gmail.com"; $sitename = "mypage"; $country = trim($_POST["country"]); $price = trim($_POST["totalprice"]); $key_to_txt = array('austria' => 'Австрия'); Now the question is: The problem is that the $ price variable does not come to me, that is, it is considered to be in the form, but it does not come to me. And the names of the countries also come only in Latin. How can I solve the problem of translation and pulling the result from the form?
valuecomes to the server. - u_muldertext()method. - u_mulder