PIbd-22_Karamushko_M_K_Pizz.../Pizzeria/PizzeriaClientApp/Views/Home/Create.cshtml
2023-03-28 08:52:39 +04:00

50 lines
1.2 KiB
Plaintext

@{
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="pizza" name="pizza" class="form-control" asp-items="@(new SelectList(@ViewBag.Pizzas, "Id", "PizzaName"))"></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>
$('#pizza').on('input', function () {
check();
});
$('#count').on('input', function () {
check();
});
function check() {
var count = $('#count').val();
var pizza = $('#pizza').val();
if (count && pizza) {
$.ajax({
method: "POST",
url: "/Home/Calc",
data: { count: count, pizza: pizza },
success: function (result) {
$("#sum").val(result);
}
});
};
}
</script>