I’m using the following code in order to gather the info I need to an email , and send it all to the controller.
Now , I’m using findAll to get all the users I need from the DB , but in the confirmation message the count=1 despite the fact that the findAll line is working in the controller and finds 220 users.
How to I pass all the @users to var checked?
<?php
$users=Person::model()->findAllByAttributes(array('status_id'=>"active"));
Yii::app()->clientScript->registerScript('sendAll','
$("#senderAll").click(function(){
var checked='.$users.'; // <------the line in question
var subject=$("#subject").val();
var message=$("#message").val();
var count=checked.length;
if(count>0 && confirm("Are you sure you want to send "+count+" emails?"))
{
$.ajax({
data:{subject:subject,message:message},
url:"'.CHtml::normalizeUrl(array('Person/senderAll')).'",
success:function(){window.location="index.php?r=person/admin"},
});
}
});
');
?>
Thanks ,
Mark.