【发布时间】:2020-02-22 20:52:11
【问题描述】:
我有一个表格,教师可以在其中为班级中的学生添加分数。问题是分数输入提交后,输入字段不保留提交的值。
我希望这些输入字段保持各自的值,以便教师在返回表单时能够看到他们之前添加的分数。
这是我的表格...
<div class="col-lg-1">
<label>Test1 </label>
<input type="hidden" name="session_id[]" value="<?php echo $sessionID; ?>">
<input type="number" name="mt_ca1[]" class="form-control input-sm rounded-0" value="<?php echo set_value('mt_ca1[]'); ?>">
</div>
<div class="col-lg-1" id="t2">
<label>Test2</label>
<input type="number" name="mt_ca2[]" class="form-control input-sm rounded-0" value="<?php echo set_value('mt_ca2[]'); ?>">
</div>
<div class="col-lg-1" id="assg">
<label>Test3</label>
<input type="number" name="mt_ca3[]" class="form-control input-sm rounded-0" value="<?php echo set_value('mt_ca3[]'); ?>">
</div>
还有控制器……
function assigngradeActionMT()
{
for($i=0; $i<count($this->input->post('number')); $i++)
{
$data[]=array(
'section_id' => $this->input->post('section_id')[0],
'subject_id' => $this->input->post('subject_id'),
'class_id' => $this->input->post('class_id')[$i],
'student_id' => $this->input->post('student_id')[$i],
'session_id' => $this->input->post('session_id')[0],
'mt_ca1' => $this->input->post('mt_ca1')[$i],
'mt_ca2' => $this->input->post('mt_ca2')[$i],
'mt_ca3' => $this->input->post('mt_ca3')[$i],
'mt_ca4' => $this->input->post('mt_ca4')[$i],
'mt_project' => $this->input->post('mt_project')[$i],
'mt_affective' => $this->input->post('mt_affective')[$i],
'mt_psychomotor' => $this->input->post('mt_psychomotor')[$i],
'mt_exam'=> $this->input->post('mt_exam')[$i],
'mt_tot_score'=> $this->input->post('mt_ca1')[$i] + $this->input->post('mt_ca2')[$i] + $this->input->post('mt_ca3')[$i] + $this->input->post('mt_ca4')[$i] + $this->input->post('mt_project')[$i] + $this->input->post('mt_affective')[$i] + $this->input->post('mt_psychomotor')[$i] + $this->input->post('mt_exam')[$i],
);
}
$inserted = $this->mtprimary_model->add1($data);
if($inserted > 0)
{
$this->session->set_flashdata('msg', '<div class="alert alert-success">Grade Added successfully</div>');
redirect('admin/mtprimary/index');
}
}
【问题讨论】:
标签: php html codeigniter