-2
Hello!
I have this View where I update the value and quantity of a product in the Database by selecting it in Viewbag, works perfectly.
I populate this Viewbag as follows in Controller:
ViewData["ProductId"] = new SelectList(_context.Product, "Id", "ProductName");
Product table has Id, Productname, Productquantity and Productprice.
My problem is:
I want to put two more inputs (or something similar) on that screen, which show the current quantity(Productquantity) and price(Productprice) according to the selected product, more or less like this:
The view code (with the inputs I want to fill in) is here:
<form asp-action="AddRemoveProduct">
<div class="row">
<div class="col-md-12">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="ProductId" class="control-label"></label>
<select id="idProduto" asp-for="ProductId" class="idProduto form-control" asp-items="ViewBag.ProductId"></select>
<input class="control-label"type="text" placeholder="Quantidade atual aqui" />
<input class="control-label" type="text"placeholder="Preço atual aqui"/>
<span asp-validation-for="ProductId" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Quantity" class="control-label"></label>
<input asp-for="Quantity" class="form-control" placeholder="Quandidade a Adicionar ou Remover" />
<span asp-validation-for="Quantity" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Price" class="control-label"></label>
<input asp-for="Price" class="form-control" placeholder="Alterar Valor do Produdo" />
<span asp-validation-for="Price" class="text-danger"></span>
</div>
</div>
</div>
<div>
<input type="submit" value="Confirmar" class="btn btn-success" />
</div>
</form>
How could I do that? It would be with Javascript, with some Razor feature... I’ve done all my research and I can’t find anything to solve my problem.
Please, before you vote negative, tell me what I’m missing in the question or what I could do. I’m starting as a programmer and I’ve been racking my brain for days on this.