I have a GridView and in my ActionColumn , there is a "View Payslip" button on each row. "Create Payslip" will be seen instead of "View Payslip" if the user has not created any payslip yet. I also have a button outside this GridView named "Approve Payslips". This button is disabled by default and will only be enabled if all buttons indicate "View Payslip".

PHP

This is code for the "Approve Payslips" button:

<?php echo Html::button('Approve Payslips', ['value' => 'approve-w', 'class' => 'btn btn-warning btn-responsive approve-w', 'style' => 'display:none', 'onclick'=>'approveWeekly(value)']); ?>

JavaScript

I tried this but it doesn't work since it passes an ID and I have multiple values to pass:

function approveWeekly(id){ $.ajax({ url: 'index.php?r=periods/approveweekly', dataType: 'json', method: 'GET', data: {id : id}, success: function (data, textStatus, jqXHR) { $.pjax.reload({container:'#w_gridview'}); }, error: function (jqXHR, textStatus, errorThrown) { alert("error"); } }); }

Also tried this one but it's not working again because I just got this code from my "Email Selected Payslips" button (check the photo above):

function approveBiMonthly(){ var keylist = $('#b_gridview').yiiGridView('getSelectedRows'); //alert(keylist); keylist = '\''+keylist+'\''; $.ajax({ url: 'index.php?r=periods/approvebimonthly', // your controller action dataType: 'json', method: 'GET', data: {keylist: keylist}, success: function (data, textStatus, jqXHR) { //alert(keylist); }, error: function (jqXHR, textStatus, errorThrown) { alert('error'); } }); }