I am new to yii. I am trying to pass a list of parameters from js to my controller in the event of 'on click' of a button.
My code is (in the view named 'studentReport'):
echo CHtml::submitButton('post' ,array('onclick'=>'js:passParams()', 'type' => 'POST',
,'name' => 'approveBtn'));
My js code inside the same form:
function passParams(){
var selctedbox = [];
for(var i=0; i<fields.length; i++){
selctedbox .push(fields[i].value);
}
$.post( <?php echo "'" . $this->createUrl('student/post') ."'" ; ?>,
{ idList: selctedbox } );
}
My controller code is:
public function actionPost()
{
$newList= array();
$idListe=$_POST;
foreach ($idListe['idList'] as $value) {
$newList[]=$value;
}
$this->render('_compose',array('newList'=>$newList,'model'=>$model));
}
Here I want to pass my list of values to the action actionPost().
I don't want to show passed parameters in url and open a new view with passed parameters from controller.
How should I do it?