【发布时间】:2020-04-20 14:53:13
【问题描述】:
抱歉,我是 asp.net 和 MVC 的新手。 我有一个程序从数据库中读取数据并在索引页中显示结果,每行附近都有一个复选框:
<table class="table">
<tr>
<th>
Select
</th>
<th>
@Html.DisplayNameFor(model => model.Rep_Id)
</th>
<th>
@Html.DisplayNameFor(model => model.Rep_Lot_Id)
</th>
<th>
@Html.DisplayNameFor(model => model.Rep_PDFToCreate)
</th>
<th>
@Html.DisplayNameFor(model => model.Rep_PDFCreated)
</th>
<th>
@Html.DisplayNameFor(model => model.Rep_Status)
</th>
<th>
@Html.DisplayNameFor(model => model.Rep_Type)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.CheckBox("pdf", true)
</td>
<td>
@Html.DisplayFor(modelItem => item.Rep_Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Rep_Lot_Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Rep_PDFToCreate)
</td>
<td>
@Html.DisplayFor(modelItem => item.Rep_PDFCreated)
</td>
<td>
@Html.DisplayFor(modelItem => item.Rep_Status)
</td>
<td>
@Html.DisplayFor(modelItem => item.Rep_Type)
</td>
</tr>
}
</table>
<script>
function Obtain_Lot() {
var name=...
}
</script>
我的目标是创建一个按钮,当单击该按钮时,它会将检查的项目的“model.Rep_Lot_Id”作为字符串获取。只能检查一项。我该怎么做?
【问题讨论】:
-
你可以使用jquery获取值为
checked的复选框,然后使用jquery的travel函数获取Rep_Lot_Id -
谢谢,不知道旅行的功能。我会搜索它并尝试它是否有效。
标签: javascript asp.net asp.net-mvc model-view-controller