hi there,
how to add extra param for ajax post request,
suppose that i have view like this:
$siswax=siswa_kelas::model()->findAll($criteria);
foreach($siswax as $n=>$siswa): ?>
<tr class="<?php echo $n%2?'even':'odd';?>">
<?php
$nama=siswa::model()->findbyPk($siswa->nis)->nama_lengkap;
?>
<td><?php echo $siswa->no_absen; ?></td>
<td width='55%'><?php echo $nama; ?></td>
<?php
$nilai=siswa_nilai_tugas::model()->find('nis=:id and tahun=:thn and semester=:sms and id_mapel=:mapel and tugas_ke=:nil',
array(':id'=>$siswa->nis,':thn'=>$tahun,':sms'=>$semester,':mapel'=>$id_mapel,':nil'=>$tugas))->nilai;
?>
<td>
<?php
//echo CHtml::textField('nilai['.$siswa->nis.']',$nilai);
echo CHtml::textField('nilai['.$siswa->nis.']',$nilai,array('id'=>'nilai'.$siswa->nis,
'ajax'=>array(
'type'=>'POST',
'url'=>array('simpanNilai'),
'params'=>array('id_mapel'=>$id_mapel), // is this true ? <---
'update'=>'#nick_result'
)
)); ?>
<div id="nick_result"> </div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
and here is my controller:
public function actionSimpanNilai()
{
$id_mapel=$_POST['id_mapel'];
$tugas=$_POST['tugas'];
$nilai=$_POST['nilai'];
foreach ($nilai as $nis=>$nil):
$sql="update siswa_nilai_tugas set nilai='{$nil}' where
nis='{$nis}' and id_mapel='{$id_mapel}' and tugas_ke='{$tugas}'";
Yii::app()->db->createCommand($sql)->execute();
echo $sql;
endforeach;
//print_r ($nilai);
}
how to read var $id_mapel from ajax request post?
thanks before