Help me figure out the third day!
I have on my page a pop-up list with sizes of clothes. Depending on the size chosen, the price of the product on the page should change. To work with the database, I use entity framrework. Using jquery, I created an event handler for changing the value in the list. What you need to enter in function (data) to return the html markup with the price per page.
Here is the change () event handler itself.
<script type="text/javascript"> $(document).ready(function() { $('#IdSize').change(function () { var idS = $('#IdSize').val(); var urlPrice = '@Url.Action("GetPriceForSize")'; $.post(urlPrice, { idProd: '@Model.Product.IdProduct', idSize: idS }, function(data) { ............................ }); });
This is the partitial view GetPriceForSize:
[HttpPost] public ActionResult GetPriceForSize(int idProd, int idSize) { Prices price = repository.Prices. Where(p => p.IdProd == idProd && p.IdSize == idSize). SingleOrDefault(); return Json(new { price = price.Price }); } @model haengematten.eu.Models.Prices <span class="regular-price" id="product-price-67_clone"> <span class="price">@Model.Price</span> </span>
Help me figure it out, just started studying jquery.
`