-3
Table
Checkbox Header1 Header2 Header 3
x foo foo foo
o foo foo foo
o foo foo foo
endTable
<select>
<option>1</option>
<option>2</option>
<option>3</option>
<select>
複選框ID動態添加, 「worksmart - 勾選」 +計數如。 「worksmart-checkbox1」
<table class="table table-responsive table-striped table-condensed">
<tr>
<th>
Select
</th>
<th hidden>Value</th>
<th>
@Html.DisplayNameFor(model => model.Firstname)
</th>
<th>
@Html.DisplayNameFor(model => model.Lastname)
</th>
<th>
@Html.DisplayNameFor(model => model.Address)
</th>
<th>
@Html.DisplayNameFor(model => model.Postcode)
</th>
<th>
@Html.DisplayNameFor(model => model.CaseReference)
</th>
<th>
@Html.DisplayNameFor(model => model.DateOfBirth)
</th>
<th>
@Html.DisplayNameFor(model => model.SpouseFirstname)
</th>
<th>
@Html.DisplayNameFor(model => model.SpouseLastname)
</th>
<th>
@Html.DisplayNameFor(model => model.SpouseAddress)
</th>
<th>
@Html.DisplayNameFor(model => model.SpousePostcode)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
<input type="checkbox" class="checkbox" id="@item.ElementID" />
</td>
<td hidden>@item.ApplicantID</td>
<td>
@Html.DisplayFor(modelItem => item.Firstname)
</td>
<td>
@Html.DisplayFor(modelItem => item.Lastname)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.Postcode)
</td>
<td>
@Html.DisplayFor(modelItem => item.CaseReference)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOfBirth)
</td>
<td>
@Html.DisplayFor(modelItem => item.SpouseFirstname)
</td>
<td>
@Html.DisplayFor(modelItem => item.SpouseLastname)
</td>
<td>
@Html.DisplayFor(modelItem => item.SpouseAddress)
</td>
<td>
@Html.DisplayFor(modelItem => item.SpousePostcode)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ApplicantID })
</td>
</tr>
}
</table>
我試圖讓"hidden"
td
的值在表上,其中複選框被選中的行。有很多複選框,但是如果檢查一個,其餘的都被禁用。
我想訪問位於表格外的selet標記中的onChange方法中選中的複選框的隱藏td。
$('#worksmart-select').on("change", function() {
// get first td val
});
你認爲'select'是你自己的第一個'td'嗎? – divy3993
發佈表格的HTML。同時發佈你到目前爲止已經嘗試過的。 –
選擇位於表格之外 – Haris