jquery - Bulk status update on dropdown list change -
i have drop down list bulk status upload
echo chtml::dropdownlist('updatestatus', 'updatestatus', lookup::items('nodestatus'), array( 'prompt' => '', 'ajax'=>array( 'type'=>'post', 'url' => ccontroller::createurl('node/bulkstatus'), 'data'=> array('updatestatus' => 'js:this.value', 'autoid' => 'js:$("input[name=autoid]:checked").map(function () {return this.value;}).get().join(",")'), 'success'=>'reloadgrid', 'update'=>'#msg', //selector update ), ) ); ?>
i struggling value of checked value of input checkbox in above ajax option this:
<input id="autoid_6" type="checkbox" name="autoid[]" value="11"> <input id="autoid_5" type="checkbox" name="autoid[]" value="10"> <input id="autoid_8" type="checkbox" name="autoid[]" value="6">
i have looked post in firebug , autoid empty , updatestatus working fine. want send autoid values array action can loop through array:
public function actionbulkstatus() { if(isset($_post['updatestatus'])) { $autoidall = $_post['autoid']; if(count($autoidall)>0) { foreach($autoidall $autoid) { $model=$this->loadmodel($autoid); $model->status = $_post['updatestatus']; $model->save(); } } echo "successfully update"; } }
how can pass autoid checked value array in ajax data option of dropdownlist?
keep simple. remove .join(",")
.get().join(..)
, checkboxes names should autoid
, remove []
, should fine.