CourseWork_CompShop/ComputerShopProvider/ComputerShopClientApp/Views/Home/EditComponent.cshtml

59 lines
1.9 KiB
Plaintext
Raw Normal View History

2023-05-17 17:28:31 +04:00
@using ComputerShopContracts.ViewModels;
@using ComputerShopDataModels.Models;
@{
ViewData["Title"] = "EditComponent";
}
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Сборка: </label>
<div class="u-input u-input-rectangle">
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components, "Id", "ComponentName"))"></select>
</div>
</div>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Название компонента</label>
<input type="text"
id="componentName"
placeholder="Введите название компонента"
name="componentName"
class="u-input u-input-rectangle" />
</div>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Цена сборки</label>
<input type="text"
id="price"
placeholder="Введите цену компонента"
name="price"
class="u-input u-input-rectangle" />
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>
@section Scripts
{
<script>
function check() {
var component = $('#component').val();
if (component) {
$.ajax({
method: "GET",
url: "/Home/GetComponent",
data: { componentId: component },
success: function (result) {
$('#componentName').val(result.componentName);
$('#price').val(result.Cost.ToString());
}
});
};
}
check();
$('#component').on('change', function () {
check();
});
</script>
}