Having trouble with an asp.net listview that contains two buttons, a textbox, and label in each row.
When one of the buttons is clicked, a javascript function should be triggered. This function is supposed to take the value from the textbox and initiate a countdown in the corresponding label.
The issue arises when the function always takes the value from the first row of the listview instead of the selected row. Many attempts have been made to resolve this, but the correct row's value is still not being used.
Seeking guidance on how to ensure the function retrieves and sets the accurate values for each row.
Thank you
function countdown() {
interval = setInterval(function () {
var lbl = document.getElementById("ctl00_ContentPlaceHolder1_lstViewFormulas_ctrl0_lblCountDown");
var txt = document.getElementById("ctl00_ContentPlaceHolder1_lstViewFormulas_ctrl0_txtTimeMinutes");
<asp:Button ID="buttStartTimer" runat="server" OnClientClick="javascript:countdown()" Text="Start" />
<asp:Button ID="buttStopTimer" runat="server" OnClientClick="javascript:stopcountdown()" Text="Stop" />
<asp:TextBox runat="server" ID="txtTimeMinutes" Text='<%#Eval("FormulaTiming")%>'></asp:TextBox>
<asp:Label ID="lblCountDown" runat="server" Text=""></asp:Label>
Other Attempts
<%--<input type="button" onclick='countdown()'; value="Start" id="Start" />
<input type="button" onclick='stopcountdown()'; value="Stop" id="Stop" />--%>
<%--<input type="button" onclick='countdown(this.form.TimeMinutes, this.form.spCountDown)'; value="Start" id="Start" />
<input type="button" onclick='stopcountdown()'; value="Stop" id="Stop" />--%>
<%-- <input type="button" onclick='<%# Eval("FormulaTiming", "countdown({0});")%>' value="Start" id="Button2" />
<input type="button" onclick='stopcountdown()'; value="Stop" id="Button3" />--%>
<%--<input type="text" value='<%#Eval("FormulaTiming")%>' id="txtTimeMinutes" />--%>