jquery - Which i should use for my View? -


i have view :

 <table id="cartbox">             <thead>                 <tr>                     <th>tên hàng</th>                     <th>số lượng</th>                     <th>Đơn giá</th>                     <th colspan="2" style="width:70px">thành tiền</th>                 </tr>             </thead>             <tbody>                 @foreach (var line in model.cart.lines)                 {                     <tr>                          <td>@line.product.name                         </td>                         <td class="qty">@html.dropdownlist("quantity", new selectlist(viewbag.items system.collections.ilist, "value", "text", line.quantity))</td>                         <td style="color:#3a9504;margin-left:3px" class="price">@string.format("{0:00,0 vnĐ}", line.product.price)</td>                         <td class="subtotal">@string.format("{0:00,0 vnĐ}", (line.quantity * line.product.price))</td>                         <td align="center" style="width:10px"><a href="@url.action("removefromcart","cart",new{proid= line.product.productid, returnurl= request.url.pathandquery})"><img src="@url.content("~/content/images/delete.png")" style="padding-right:10px" /></a></td>                     </tr>                 }              </tbody>             <tfoot>                 <tr style="border-top-style:solid;border-top-color:#dfdfdf;border-top-width:1px;">                     <td colspan="3" align="right" style="border-right-color:#808080;border-right-style:solid;border-right-width:1px;text-align:right"><b>tổng tiền:</b></td>                     <td style="text-align: center"><b>@string.format("{0:00,0 vnĐ}", model.cart.computetotalvalue())</b></td>                     <td></td>                 </tr>             </tfoot>         </table> 

which jquery ajax function should use update subtotal & total when user change quantity on dropdownlist:

function calvalue() { $("#select").change(function () {     var quantity = $(this).val();     var fprice = $(this).closest("tr").find("td[class^=price]").html();     var price = fprice.replace(/[,\s(vnĐ)]/g, '')     var fsubtotal = parseint(quantity) * parseint(price);     var subtotal =      $(this).closest("tr").find("td[class^=subtotal]").html(subtotal); }); 

}

the problem function after refresh page, page return orgrinal value, nothing changes. or

   function updatevalue() {     $(document.body).on("change", ".quantity", function () {         var proid = $(this).attr("data");         var quatity = $(this).val();         $.ajax({             type: "get", url: "/cart/updatevalue",             data: { proid: proid, quantity: quatity },             success: function (data) {                 $("#cartbox").html(data);             }         }             );         $.ajaxsetup({             cache: false         });     }); } 

and problem return new view, dropdownlist duplicated in view.

anyone can tell me how can control or use method? please.

if want save information on client side have following options:

  1. send server , store in session , durring view render use information
  2. use local storage on client side , after reload check if local storage has data , use them properly

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -