я же выложил полный код
<script>
$(document).ready(function(){
var t = $('div.inputs input').size();
$('#add').click(function() {
$('<div><input type="text" class="field" name="dynamic[]" /> <input type="text" class="field" name="dynamic[]" /></div>').fadeIn('slow').appendTo('.inputs');
t++;
if(t==6){
$('#add').hide()
}
});
$('#remove').click(function() {
if(t > 1) {
$('.field:last').remove();
$('.field:last').remove();
t--;
$('#add').show()
}
});
$('#reset').click(function() {
while(t > 2) {
$('.field:last').remove();
$('.field:last').remove();
t--;
$('#add').show()
}
});
// here's our click function for when the forms submitted
$('.submit').click(function(){
var answers = [];
$.each($('.field'), function() {
answers.push($(this).val());
});
// Отсылаем паметры
$.ajax({
type: "POST",
url: "new.php",
data: "data="+answers,
// Выводим то что вернул PHP
success: function(html) {
//предварительно очищаем нужный элемент страницы
$("#result").empty();
//и выводим ответ php скрипта
$("#result").append(html);
}
});
return false;
});
});
</script>
<div id="container">
<div class="dynamic-form">
<a href="#" id="add">Добавить</a> | <a href="#" id="remove">Удалить</a> | <a href="#" id="reset">Сбросить</a>
<form>
<div class="inputs">
<div><input type="text" name="dynamic[]" class="field" >
<input type="text" name="dynamic[]" class="field" ></div>
</div>
<input name="submit" type="button" class="submit" value="ОК">
</form>
<div id="result"></div>
</div>