Hello everybody, I'm using data tables to show questions from a survey. Questions are shown one per page. When user click the "next" button, he sees the next question, and finally he sees submit button. But it does not work, it does not send the form. Here's my code:
```
<html>
<head>
<link rel="stylesheet" href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.min.css" type="text/css" />
$(document).ready(function() {
$('#example').dataTable( {
"pagingType": "simple",
"lengthMenu": [[1], [1]],
"bSort": false
} );
} );
</head>
<body>
<br/><br/>
<?php
$survey_id = $this->uri->segment(3);
Въпрос |
<?php
echo validation_errors();
foreach ($survey as $row)
{
$row->question_id=$this->uri->segment(4);
$question_id=$this->uri->segment(4);
?>
<tr>
<?php
$attributes = array('id' => 'myform');
echo form_open('index/survey_fill/' .$survey_id , $attributes); ?>
<td>
<?php echo "$row->question"; ?><br/>
<?php echo "<input type='hidden' name='question_id' value='$row->question_id' />"; ?>
$data=array(
'name' => 'answer['.$row->question_id.']',
'value' => '5'
);
echo "<input type='hidden' name='survey_id' value='$row->survey_id'>"; ?>
<?php echo "<input type='hidden' name='question_id' value='$row->question_id' />";
echo form_radio($data);
echo "5 ";
$data=array(
'name' => 'answer['.$row->question_id.']',
'value' => ' 4'
);
echo form_radio($data);
echo " 4";
</td></tr>
<?php
}
<?php
>
<?php echo form_close(); ?>
|
```
My Model is:
```
public function survey_fill()
{
$answers=($this->input->post('answer'));
if (null !==($this->input->post('submit'))) {
$date = new DateTime("now");
foreach($answers as $question_id=>$answer)
{
$data = array(
'user_id'=>$this->session->userdata['user_id'],
'question_id'=>$question_id,
'answer'=>$answer,
'created_at'=>$date->format('Y-m-d H:i:s')
);
$this->db->insert('survey_answers', $data);
}
if($this->db->affected_rows() > 0)
{
return true;
}
return false;
}
}
```
?>