47 lines
1.3 KiB
Plaintext
47 lines
1.3 KiB
Plaintext
@{
|
|
ViewData["Title"] = "UpdateOrder";
|
|
}
|
|
<div class="text-center">
|
|
<h2 class="display-4 mb-5">Обновить заказ</h2>
|
|
</div>
|
|
<form method="post">
|
|
<div class="row mb-3">
|
|
<div class="col-4">Заказ:</div>
|
|
<div class="col-8">
|
|
<select id="order" name="order" class="form-control" asp-items="@(new SelectList(@ViewBag.OrdersForProducts,"Id", "OrderDate"))"></select>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-4">Дата:</div>
|
|
<div class="col-8"><input type="date" id="date" name="date" /></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-4">Товар:</div>
|
|
<div class="col-8">
|
|
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Orders,"Id", "OrderName"))"></select>
|
|
</div>
|
|
</div>
|
|
<div class="text-center ">
|
|
<input type="submit" value="Обновить" class="btn btn-success ps-5 pe-5" />
|
|
</div>
|
|
</form>
|
|
<<script>
|
|
$('#order').on('change', function () {
|
|
getData();
|
|
});
|
|
|
|
function getData() {
|
|
var orderId = $('#order').val();
|
|
var orderData = @Html.Raw(Json.Serialize(ViewBag.Orders));
|
|
var selectedOrder = orderData.find(function (order) {
|
|
return order.id == orderId;
|
|
});
|
|
|
|
if (selectedOrder) {
|
|
$("#date").val(selectedOrder.date);
|
|
$("#product").val(selectedOrder.orderId).change();
|
|
}
|
|
}
|
|
|
|
</script>
|