PIbd-23-Volkov-N.A.-Compute.../ComputersShop/ComputersShopClientApp/Views/Home/Create.cshtml

52 lines
1.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@{
ViewData["Title"] = "Create";
}
<div class="text-center">
<h2 class="display-4">Создание заказа</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Компьютер:</div>
<div class="col-8">
<select id="computer" name="computer" class="form-control" asp-items="@(new SelectList(@ViewBag.Сomputers,"Id", "ComputerName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Количество:</div>
<div class="col-8"><input type="text" name="count" id="count"></div>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8"><input type="text" id="sum" name="sum" readonly></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary"/>
</div>
</div>
</form>
<script>
$('#computer').on('change', function () {
check();
});
$('#count').on('change', function () {
check();
});
function check() {
var count = $('#count').val();
var computer = $('#computer').val();
if (count && computer) {
$.ajax({
method: "POST",
url: "/Home/Calc",
data: { count: count, computer: computer },
success: function (result) {
$("#sum").val(result);
}
});
};
}
</script>