當我將選擇複選框,並將點擊選擇按鈕如何我可以得到這個值的文本框的值。這裏checkbox id = chk和textbox id = OrderNo。請幫我....我有下面的東西....如何獲取mvc中的複選框值?
$("#OrderNo").blur(function() {
$.get('/Ordering/OrderList/', function(data) {
$('#orlist').html(data);
});
$('#orlist').dialog({
width: 500,
height: 350,
open: true,
title: 'Select Order',
buttons: {
Select: function() {
if (("#chk") == 'checked') {
var por = ("#porderno").val();
por = ("#OrderNo");
}
},
Cancel: function() {
$('#orlist').dialog('close');
$('#orlist').empty();
}
}
});
局部視圖頁面
@model IEnumerable<testcon.OrderM>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.OdrId)
</th>
<th>
@Html.DisplayNameFor(model => model.OrderNo)
</th>
<th>
@Html.DisplayNameFor(model => model.CId)
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.CheckBox("OdrId", new { @id="chk"})
</td>
<td class="left">
@Html.DisplayFor(modelItem => item.OrderNo, new { @id="porderno"})
</td>
<td class="left">
@Html.DisplayFor(modelItem => item.CId)
</td>
</tr>
}
</table>
和我的創建視圖頁面
@model testcon.DeliveryInfo
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>DeliveryInfo</legend>
@*<div class="editor-label">
@Html.LabelFor(model => model.DId)
</div>*@
<div class="editor-field">
Delivery Id : @Html.EditorFor(model => model.DId)
@Html.ValidationMessageFor(model => model.DId)
</div>
@*<div class="editor-label">
@Html.LabelFor(model => model.OrderNo)
</div>*@
<div class="editor-field">
Order No :@Html.EditorFor(model => model.OrderNo)
@Html.ValidationMessageFor(model => model.OrderNo)
@*<a href="#" onclick="javascript:getOrderList()">Show Order</a>*@
</div>
@* <div class="editor-label">
@Html.LabelFor(model => model.DDate)
</div>*@
<div class="editor-field">
Delivery Date : @Html.EditorFor(model => model.DDate)
@Html.ValidationMessageFor(model => model.DDate)
</div>
@*<div class="editor-label">
@Html.LabelFor(model => model.DQuantity)
</div>*@
<div class="editor-field">
Delivery Quantity: @Html.EditorFor(model => model.DQuantity)
@Html.ValidationMessageFor(model => model.DQuantity)
</div>
@*<div class="editor-label">
@Html.LabelFor(model => model.DAmount)
</div>*@
<div class="editor-field">
Delivery Amount : @Html.EditorFor(model => model.DAmount)
@Html.ValidationMessageFor(model => model.DAmount)
</div>
<div id="orlist" >
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
你能證明你的HTML代碼 – Akhlesh
這(「#chk」),必須爲$ (「#chk」)和這個var por =(「#porderno」)。val();應該是var por =(「#porderno」)。val($((「#chk」)).val());也刪除這一行por =(「#OrderNo」);我不明白爲什麼。 – rgdesign
@akhlesh我已更新我的html代碼 – MNAH