在javascript中将项目推送到数组中

Kra*_*mer 0 javascript asp.net-web-api

我遇到了一个关于JavaScript的问题.具体来说,我有一张桌子

<table class="table">
    <tr>
        <th>
            <label>Select</label>
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Middle)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.LastName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.DoB)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Gender)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.StartDate)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr id="@Html.DisplayFor(modelItem => item.EmployeeId)" ondblclick="DoubleClickOnRow(this)">
        <td>
            <input id="@Html.DisplayFor(modelItem => item.EmployeeId)" type="checkbox" onclick="SelectCheckBox(this)"/>
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FirstName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Middle)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LastName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DoB)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Gender)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.StartDate)
        </td>
    </tr>
}
</table>
Run Code Online (Sandbox Code Playgroud)

我声明了一个数组来保持EmployeeId不检查行的第一列中的复选框.但是,它表示arrayOfEmployeeId.push(id); 不是一个功能.顺便说一下,我希望在ASP.NET web api中获取EmployeeId数组来执行DELETE方法.我对吗?

var arrayOfEmployeeId = {};
function SelectCheckBox(thisRow)
    {
        var id = thisRow.id;
        arrayOfEmployeeId.push(id);
        console.log(arrayOfEmployeeId);
    }
Run Code Online (Sandbox Code Playgroud)

str*_*str 5

arrayOfEmployeeId是一个对象({}).你可能想要的是像一个数组var arrayOfEmployeeId = [];.