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>
OnChange ersten td Wert zu erhalten, wenn Checkbox
Checkbox-ID überprüft dynamisch hinzugefügt werden, "Worksmart-Checkbox" + zählen zB. „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>
Ich versuche, den Wert des "hidden"
td
in der Tabelle auf die Reihe zu bekommen, wo das Kontrollkästchen aktiviert ist. Es gibt viele Checkboxen, aber wenn man angekreuzt ist, sind alle anderen deaktiviert.
Ich mag die versteckte td des geprüften Checkbox in der onChange Methode in einem Selet Tag zuzugreifen, die außerhalb der Tabelle sitzt.
$('#worksmart-select').on("change", function() {
// get first td val
});
Betrachten Sie 'select' als Ihr erstes' td' selbst? – divy3993
Veröffentlichen Sie den HTML-Code für die Tabelle. Schreiben Sie auch, was Sie bisher versucht haben. –
die Auswahl sitzt außerhalb der Tabelle – Haris