0
我正在开发一个MVC应用程序。 我正在索引视图/表中显示数据。如何在MVC 3视图中的JS中获取模型项数据?
我在最后一列添加了额外的复选框。 当用户点击该复选框时,我想从该选定/检查行的特定列中获取值。
我想在JS的警报窗口中显示该值,但它不显示。
如何做到这一点。
@model PagedList.IPagedList<PaymentAdviceEntity.PaymentAdvice>
<table class="table table-striped">
<tr>
<th>Company
</th>
<th>
Amount
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Company.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.SanctionedAmount,"sAmount","sAmount")
</td>
<td>
@Html.CheckBox("IsPaid", (bool)item.IsPaid, new { @value=item.Id,@class="IsPaid-"+item.Id})
</td>
</tr>
</table>
<script type="text/javascript">
$("input[type='checkbox']").click(function() {
if ($(this).is(":checked"))
{
var nPaid = $("#sAmount").val();
alert(nPaid);
}
});
</script>
在所有 – Nil 2013-03-26 11:10:15
PLS不工作,等待3分钟我会改变你的代码 – user571874 2013-03-26 11:14:12
这是正确的代码?我不这么认为 – Nil 2013-03-26 11:22:28