PIbd-23_Ivanov_V.N._Pizzeria/Pizzeria/PizzeriaClientApp/Views/Home/Create.cshtml

50 lines
1.2 KiB
Plaintext
Raw Normal View History

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