function showModalWin() { var darkLayer = document.createElement('div'); darkLayer.id = 'shadow'; document.body.appendChild(darkLayer); var modalWin = document.getElementById('feedback-form'); modalWin.style.display = 'block'; darkLayer.onclick = function () { darkLayer.parentNode.removeChild(darkLayer); modalWin.style.display = 'none'; return false; }; } document.getElementById('feedback-form').addEventListener('submit', function(evt){ var http = new XMLHttpRequest(), f = this; evt.preventDefault(); http.open("POST", "http://localhost/views/product/contact.php", true); http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.send("nameFF=" + f.nameFF.value + "&contactFF=" + f.contactFF.value + "&phoneFF=" + f.productFF.value + "&productFF=" + f.phoneFF.value + "&messageFF=" + f.messageFF.value); http.onreadystatechange = function() { if (http.readyState == 4 && http.status == 200) { alert(http.responseText + ', Ваше сообщение получено.\nНаши специалисты ответят Вам в течении 2-х дней.\nБлагодарим за интерес к нашей фирме!'); f.messageFF.removeAttribute('value'); f.messageFF.value=''; } } http.onerror = function() { alert('Извините, данные не были переданы'); } }, false); 
 #feedback-form { max-width: 400px; padding: 2%; border-radius: 3px; background: #f1f1f1; font: 16px/30px Arial, Tahoma, Verdana, sans-serif; z-index:2; top: 9%; right: 0; left: 0; margin: 0 auto; /*display: none;*/ position: fixed; } 
 <form method="POST" id="feedback-form" > Выбран продукт: <input type="text" name="productFF" required value="<?php echo $product['name']; ?>" readonly> Как к Вам обращаться: <input type="text" name="nameFF" required placeholder="Фамилия Имя Отчество" x-autocompletetype="name" > Email для связи: <input type="email" name="contactFF" required placeholder="Адрес электронной почты" x-autocompletetype="email"> Контактный телефон: <input type="tel" name="phoneFF" required placeholder="Номер телефона" x-autocompletetype="phone"> Ваш комментарий: <textarea name="messageFF" required rows="5"></textarea> <input class="to-cart" type="submit" value="Отправить"> </form> 

  • Perhaps you forgot to tell you what you need from this code ... - mymedia
  • how to close a modal window after sending data from a form - Ruscope
  • document.getElementById('feedback-form').style.display = "none"; - Igor
  • Exactly! Another question is how to disable the #shadow style (blackout) - Ruscope
  • document.getElementById('shadow').parentNode.removeChild(document.getElementById('shadow')); - Igor

0