This is the html form:
<form id="contactRefer" method="POST" action="submit.php">
<input type="email" name="email[email-0]" required >
<input type="text" name="mobile[mobile-0]" required >
.
.
.
<input type="hidden" value="2" id="count" name="count">
<a style="cursor:pointer;" id="more-friends">Add More Friends </a>
<button class="btn btn-success" type="submit" id="frmSubmit">Send</button>
The jQuery I am using is as follows. Please note that I want to use dynamically added input box also.:
$("#more-friends").click(function(){
var i = parseInt($('#count').val())+1;
$('.new-friends').append('<div class="col-md-12"><div class="col-md-6"><div class="form-group"><input type="email" name="email[email-'+i+']" placeholder="Enter Email Id" class="form-control" data-validetta="email"></div></div><div class="col-md-6"><div class="form-group"><input type="text" name="mobile[mobile-'+i+']" placeholder="Enter Mobile Number" class="form-control" data-validetta="minLength[10],maxLength[15]"></div></div></div>');
$('#count').val(i);
});
$("#frmSubmit").on('click', function(){
$.ajax({
type : "POST",
url : "submit.php",
data : $("#contactForm").serialize(),
datatype : 'text',
success: function(data) {
alert(data);
}
});
});
I want to send the whole form data using mail method in php. But before that I also want to get all the values in a string. I am not able to get that php part which converts all the POST data into php array.