You will see I want to obtain the value of the options chosen in the select
, through POST
, do I have to do a array
with the values selected ?, I tried to do something but I did not get it
View of the form
<?php if(!empty($GenerarExamen)){
foreach ($GenerarExamen as $ge) {
if($ge->idTipoPreg=='1'){ ?>
<form action="<?=base_url()?>index.php/examenEmp/Result/<?=$ge->idExamen?>/<?=$cveEmpleado?>/<?=$ge->idSolicitud?>" method="POST" class="form">
<fieldset>
<input type="hidden" name="idPregunta" value="<?=$ge->idPregunta?>">
<legend><?=$ge->pregunta?></legend>
<select name="pregunta" class="form-control" required="target" >
<option value="">Selecciona una respuesta</option>
<?php
$this->load->model('examenEmp_model');
$idPreg=$ge->idPregunta;
$Resp= $this->examenEmp_model->respuesta($idPreg);
if(!empty($Resp)){
foreach ($Resp as $t) {
?>
<option value="<?=$t->inciso?>"><?=$t->respuesta?></option>
<?php }
}?>
</select>
</fieldset>
<br>
<?php }elseif ($ge->idTipoPreg=='2') {?>
<fielset>
<input type="hidden" name="idPregunta" value="<?=$ge->idPregunta?>">
<br>
<label><?=$ge->pregunta?></label>
<br>
<textarea required="target" placeholder="Escribe tu respuesta..." class="form-control"></textarea>
</fieldset>
<?php
}
}
}
?>
<button type="submit" class="btn btn-large">Aceptar</button>
</form>
And here the code of my controller, works if I only do it with a question but I do not know how to do it with more than one. Could you help me? :)
<?php public function Result($idExamen,$cveEmpleado, $idSolicitud) {
$valor=$this->input->POST('valor');
$r=$this->input->POST('incisoCto');
$incisoS=$this->input->POST('pregunta');
if ($incisoS==$r) {
$this->examenEmp_model->agregarR($valor,$idSolicitud);
}
else{
echo "<script>
alert('No se genero examen');
</script>" ;
}
$this->data['results'] = $this->examenEmp_model->resultTeorico($idSolicitud);
$this->load->view('result_display', $this->data);
}?>