Gero fields via jquery, with a question and 2 answers, I need to collect these fields in post via php.
Gero as follows:
var length = wrapper.find(".fields").length;
$(wrapper).append('<div class="col-sm-12 fields fields'+ (length+1) +'">\
<label >Pergunta</label>\
<input type="text" value="" name="pergunta'+ (length+1) +'[]">\
<label >resposta 1</label>\
<input type="text" value="" name="resposta1'+ (length+1) +'[]">\
<label >resposta 2</label>\
<input type="text" value="" name="resposta2'+ (length+1) +'[]">\
<input type="text" value="" name="item[]">\
');
The problem in question is that in the foreach post I need to collect the answers to each question.
$size = sizeof($_POST['item']);
for ($i = 0;$i < $size;$i++)
{
echo 'pergunta:' .$_POST["pergunta1"].'<br>';
}
In this way I know there is no way to directly set the name
of the input, because it is dynamic.