title: How to get/access row value from Repeater using jquery?
body: <p>i've a jquery function for my textbox onchange event. when triggers, i want to validate the value inputted by the user in the textbox with the value from the datatable displayed by repeater. i was able to get the value of the textbox but my problem is i cant get the value (qty column) from the repeater. i put on an itemindex for the id of the row to identify the right row and get the value of column qty. in debugging mode, the variable that i used is unidentified so im not getting any value at all. I need help please, i've been struggling for this too long now.</p>
  
  <p>html</p>
  
  <pre><code>&lt;asp:Repeater ID="rptInStock" runat="server"&gt;
              &lt;ItemTemplate&gt;
                  &lt;div id="ucprodres-in-stock&lt;%# Container.ItemIndex%&gt;&gt;" class="ucprodres-in-stock"&gt;
                      &lt;div class="ucprodres-stock manufacturer"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("Mfg").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div id="instock-qtyavail" class="ucprodres-stock qty-avail"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("Qty").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock availability"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("Availability").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock unit-price"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("QtyRange").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock dollar"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("QtyRangePrice").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock qty-required instock-qtyreqd"&gt;
                          &lt;asp:TextBox ID="tbxInStock" runat="server"&gt;&lt;/asp:TextBox&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>jquery: (+itemIndex is not working also, how do i add index to the id since i used container.itemIndex to make my ids unique?)</p>
  
  <pre><code>function ValidateQty1(txtBox) {
      var qtyreqd = txtBox.value;
      var instockrow = document.getElementById("ucprodres-in-stock" + itemIndex);
      var qtyavail = instockrow.childNodes[1].nodeValue;
      if (qtyreqd &gt; qtyavail) {
          alert("The required quantity should not be greater than the available quantity");
  }
  </code></pre>
  
  <p>sample generated html</p>
  
  <pre><code>&lt;div id="ucprodres-in-stock"&gt;
  
                  &lt;div id="ucprodres-in-stock0&gt;" class="ucprodres-in-stock"&gt;
                      &lt;div class="ucprodres-stock manufacturer"&gt;
                          FAIRCHILD SEMICONDUCTOR C
                      &lt;/div&gt;
                      &lt;div id="instock-qtyavail" class="ucprodres-stock qty-avail"&gt;
                          2
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock availability"&gt;
                          In Stock
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock unit-price"&gt;
  
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock dollar"&gt;
  
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock qty-required instock-qtyreqd"&gt;
  
                          &lt;input name="MasterBasic$MasterPageContent$ucProductHeader$ucProductResults$rptInStock$ctl00$tbxInStock" type="text" id="MasterPageContent_ucProductHeader_ucProductResults_rptInStock_tbxInStock_0" onchange="ValidateQty1(this);" onkeypress="return validate(event);" /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div id="ucprodres-in-stock1&gt;" class="ucprodres-in-stock"&gt;
                      &lt;div class="ucprodres-stock manufacturer"&gt;
                          Fairchild Semiconductor Corp
                      &lt;/div&gt;
                      &lt;div id="instock-qtyavail" class="ucprodres-stock qty-avail"&gt;
                          6
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock availability"&gt;
                          In Stock
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock unit-price"&gt;
  
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock dollar"&gt;
  
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock qty-required instock-qtyreqd"&gt;
  
                          &lt;input name="MasterBasic$MasterPageContent$ucProductHeader$ucProductResults$rptInStock$ctl01$tbxInStock" type="text" id="MasterPageContent_ucProductHeader_ucProductResults_rptInStock_tbxInStock_1" onchange="ValidateQty1(this);" onkeypress="return validate(event);" /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  </code></pre>
  
  <p>Here's a sample output to better understand my scenario: when onchange triggered, i want to get the value in qty-avail where the txtbox was changed.</p>
  
  <p><img src="https://i.stack.imgur.com/iJEk1.gif" alt="enter image description here"></p>
  
  <p><strong>UPDATES:</strong>
  Jquery Function:</p>
  
  <pre><code>function ValidateQty1(txtBox) {
      var qtyreqd = txtBox.value;
      var qtyavail = $(this).parent().siblings(".qty-avail").text().trim();
      alert(qtyavail);
  }
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;asp:Repeater ID="rptInStock" runat="server"&gt;
              &lt;ItemTemplate&gt;
                  &lt;div id="ucprodres-in-stock&lt;%# Container.ItemIndex%&gt;" class="ucprodres-in-stock"&gt;
                      &lt;div class="ucprodres-stock manufacturer"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("Mfg").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div id="instock-qtyavail" class="ucprodres-stock qty-avail"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("Qty").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock availability"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("Availability").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock unit-price"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("QtyRange").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock dollar"&gt;
                          &lt;%# CType(Container.DataItem, System.Data.DataRowView).Item("QtyRangePrice").ToString%&gt;
                      &lt;/div&gt;
                      &lt;div class="ucprodres-stock qty-required instock-qtyreqd"&gt;
                          &lt;input type="text" onkeypress="return validate(event);" onchange="ValidateQty1(this);"  /&gt;
                          &lt;%--&lt;asp:TextBox ID="tbxInStock" runat="server"&gt;&lt;/asp:TextBox&gt;--%&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:Repeater&gt;
  </code></pre>