如何在javascript中添加带有checkbox属性的变量,该变量将填充view.php中的表

I have a shift.js and shift_view.php

in shift_view.php:

<div style="float:left;width:1200px;">
        <div style="float:left;width:800px;">
            <table cellpadding="0" cellspacing="0" border="0" class="display dataTable" id="main_table" aria-describedby="example_info" style="width: 100%;">
                <thead>
                    <tr role="row">
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">Select</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">ID</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">Region</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">Description</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">Start Time</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">End Time</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">$/hr</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">Ride Bonus</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">Ride Bonus Rate</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">Drivers</th>
                        <th class="sorting" role="columnheader" tabindex="0" aria-controls="example" rowspan="1" colspan="1">Edit Shift</th>
                    </tr>
                </thead>
                <tbody role="alert" aria-live="polite" aria-relevant="all">
                </tbody>
            </table>
            <br><br><br><br><br><br><br><br><br><br><br><br><br><br>

        </div>

    </div>

which sets the first row of the table,

and in shift.js:

for(var i = 0; i < 2; i++){
                var shift = response[i];

                var arr = [ I_NEED_A_CHECK_BOX_VAR,
                            shift.ID,
                            regions[shift.RegionID],
                            shift.Description,
                            shift.StartStr,
                            shift.EndStr,
                            parseFloat(shift.GuaranteeRate).toFixed(2).toString(),
                            parseFloat(shift.RideBonus).toFixed(2).toString(),
                            parseFloat(shift.RideBonusRate).toFixed(2).toString(),
                            shift.NumDrivers.toString() + " / " + shift.DriversNeeded,
                            '<font size="6" color="green"><b><a style="text-decoration:none" href="/shift/editShift/'+shift.ID+'">Edit</a></b></font>'];

                if(parseInt(shift.NumDrivers) < 0.75 * parseInt(shift.DriversNeeded)){
                    arr[arr.length-2] = '<font color="red"><b>' + arr[arr.length-2] + '</b></font>';
                }

                if(shift.StartTimestamp*1000 < Date.now() && Date.now() < shift.EndTimestamp*1000 ){
                    arr[0] = '<font size="6" color="green"><b>' + arr[0] + '</b></font>';
                }

                $('#main_table').dataTable().fnAddData(arr);

The js will populate the data to the view. what should i do to "I_NEED_A_CHECK_BOX_VAR" to make it a checkbox?

My task is to make each row selectable so when a 'submit' button is clicked, the selected row's shift.ID will be send to another function in an array.

From all the researches, I could only find that a checkbox is made in the html(view) since the view actively calles function to get data, but in this case, the view isn't, it is the js that updates the view.

thanks for all your help!! Luke

its solved!

I_NEED_A_CHECK_BOX_VAR = '<input type="checkbox" name="checkbox" id="checkbox_' + shift.ID + '" class="r1" />'

hope it helps anyone