when i will select check box and will be clicked select button how i can get this value to the textbox value. Here checkbox id= chk and textbox id = OrderNo. Please help me ....I have something in below....
$("#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();
}
}
});
Partial view page is
@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>
And My Create View page is
@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>
Use .is(':checked')
check if checked...
buttons: {
Select: function() {
if ($("#chk").is(':checked')) {
$("#OrderNo").val($("#porderno").val());
}
},
to check if the check box is checked in jQuery
, you can do it by either
//will return true if the check box is checked otherwise false!
$("#chkBoxId").is(':checked');
or
this approach is good when dealing with group of radio buttons/checkboxes.
//will yield the same result if checkbox is checked
$('input[name="chkBoxName"]:checked').val();
So you can use them in your code like what @ Anthony Chu has responded which i was about to write :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.