-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform-groot.js
48 lines (43 loc) · 1.38 KB
/
form-groot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$( document ).ready(function() {
$(".price-form-wrap").find("input[type=submit]").val("Узнать");
$(".price-form-wrap").find("input#desc").hide();
$(".mainform").submit(function(e){
e.preventDefault();
var $this = $(this);
var data ={};
$this.find('input').each(function(){
var $el = $(this);
var key =$el.attr('name');
if(key){
data[key]=$el.val();
}
});
var specform_id = $this.parent().data('id');
$(".mainform select[name=specform] option")[specform_id].getAttribute("value");
var selected_lead = $this.find('select[name=leadsource]').find('option[selected]').val();
data.leadsource = selected_lead;
var selected_spec = $(".mainform select[name=specform] option")[specform_id].getAttribute("value");
data.specform = selected_spec;
var formURL = $(this).attr("action");
var messAddr = 'thankyou/masseg_ok.php';
$.post(formURL, data)
.done(function(){
$('input').attr('disabled','disabled');
$("input[type=submit]").val("Спасибо за заявку!");
$("#success-ajax").modal('show');
console.log(data);
})
.fail(function(){
alert('not good');
});
$.post(messAddr, data)
.done(function(){
console.log('sent');
})
.fail(function(){
console.log('wronk');
});
//STOP default action
return false;
});
});