I don’t know if it’s the right way, but I’d do it this way:
html
<form>
<div class="etapa">
<input type="hidden" name="cod_pergunta" value="1" />
<input type="hidden" name="cod_seq_questionario" value="1" />
Pergunta nro 1
<select name="resposta">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<button type="submit">Avançar</div>
</div>
</form>
<form>
<div class="etapa">
<input type="hidden" name="cod_pergunta" value="2" />
<input type="hidden" name="cod_seq_questionario" value="2" />
Pergunta nro 2
<select name="resposta">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<button type="submit">Avançar</div>
</div>
</form>
<form>
<div class="etapa">
<input type="hidden" name="cod_pergunta" value="3" />
<input type="hidden" name="cod_seq_questionario" value="3" />
Pergunta nro 3
<select name="resposta">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<button type="submit">Avançar</div>
</div>
</form>
javascript
jQuery(function(){
jQuery("form").submit(function(){
var dados = jQuery(this).serialize();
jQuery.ajax({
url : 'salvar_respostas.php',
data : dados,
type : 'post'
});
});
});
php
if ( $_POST ){
$agora = date("Y-m-d H:i:s");
$strSQL = "INSERT INTO pv_resposta (cod_formulario, cod_pergunta, resposta, cod_seq_questionario, time_click) VALUES ('3', '" . $_POST['cod_pergunta'] . "', '" . $_POST['resposta'] . "', '" . $_POST['cod_seq_questionario'] . "', '" . agora . "');"
//Executar inserção dos dados no banco
}
Please avoid long discussions in the comments; your talk was moved to the chat
– Maniero