In my application i am listing ProdutId(not visible to user), Oty(ordered by user) and other information.When i click button i want to loop
this list and retrieve product id and qty from html elements.All elements in list i am giving id. How can overcome this issue?
Below I am providing my dynamic code to generate my list
You can loop through HTML element quite easily using jQuery Each method in your code.
Helping you always. Don't forget to click "Mark as Answer" on the post that helped you.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
Member
35 Points
156 Posts
Loop through html elements and retrieve value
Jun 18, 2020 06:03 AM|binustrat|LINK
In my application i am listing ProdutId(not visible to user), Oty(ordered by user) and other information.When i click button i want to loop
this list and retrieve product id and qty from html elements.All elements in list i am giving id. How can overcome this issue?
Below I am providing my dynamic code to generate my list
$("#divViewCart").append("<div id=divCartParentList;style=width:300px;height:200px;background-color:orange>"
+ "<span id=spnCartProdName" + value.Id + ">" + value.ProductName + "</span>"
+ "<span id=spnCartProdBrand" + value.Id + ">" + value.BrandName + "</span>"
+ "<span id=spnCartProdPrice" + value.Id + ">" + value.ProdPrice + "</span>"
+ "<input type=button id=btnDecreaseQty-" + value.Id + " value =- onClick = DecreaseQty(this.id) /> "
+ "<span id=spnCartProdQty" + value.Id + ">" + value.Qty + "</span>"
+ "<input type=button id=btnIncreaseQty-" + value.Id + " value =+ onClick = IncreaseQty(this.id) /> "
+ "<input type=hidden id=hdnCartProdId" + value.Id + " value=" + value.Id + "/>"
+ " <span id=spnCartItemPTotalrice" + value.Id + ">" + parseInt(value.Qty) * parseInt(value.ProdPrice) + "</span> "
+ TotalAmount + " </div >"
)
I want to retrieve bolded value
Participant
1253 Points
935 Posts
Re: Loop through html elements and retrieve value
Jun 19, 2020 03:45 AM|yogyogi|LINK
You can loop through HTML element quite easily using
jQuery Each method
in your code.♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠