PIbd-21_Kouvshinoff_T._A._A.../AutomobilePlant/AutomobilePlantClientApp/Views/Home/Create.cshtml
2024-04-05 23:37:18 +04:00

55 lines
1.5 KiB
Plaintext

@{
ViewData["Title"] = "Create";
}
<div class="text-center">
<h2 class="display-4">Create order</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Car:</div>
<div class="col-8">
<select id="car" name="car" class="form-control" asp-items="@(new SelectList(@ViewBag.Cars,"Id", "CarName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Count:</div>
<div class="col-8">
<input type="text" name="count" id="count" />
</div>
</div>
<div class="row">
<div class="col-4">Sum:</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="Create" class="btn btn-primary" />
</div>
</div>
</form>
<script>
$('#car').on('change', function () {
check();
});
$('#count').on('change', function () {
check();
});
function check() {
var count = $('#count').val();
var car = $('#car').val();
if (count && car) {
$.ajax({
method: "POST",
url: "/Home/Calc",
data: { count: count, car: car },
success: function (result) {
$("#sum").val(result);
}
});
};
}
</script>