2016-05-17 73 views
0

我想用Javascript循環表單,但我的問題是我有第一種形式的另一種形式。通過包含另一個表單的表單循環

我想循環遍歷第一個表單,而不是內部表單。我在另一篇文章中發現了這種方法:

var table = $("#table_cultures tbody"); 

table.find('tr').each(function (i) { 
    var $tds = $(this).find('td'), 
     productId = $tds.eq(0).text(), 
     product = $tds.eq(1).text(), 
     Quantity = $tds.eq(2).text(); 

    // do something with productId, product, Quantity 

    alert('Row ' + (i + 1) + ':\nId: ' + productId 
      + '\nProduct: ' + product 
      + '\nQuantity: ' + Quantity); 
}); 

此方法的工作原理是循環兩種形式。

編輯1:

的HTML看起來像:

<form> 
    <table> 
     <tr> 
      <td>Something here</td> 
     </tr> 
     <tr> 
      <td> 
       <form> 
        <table> 
         //tr td ... 
        </table> 
       </form> 
      </td> 
     </tr> 
    </table> 
</form> 
+1

你能提供給我們HTML,所以我們可以看到你需要什麼嗎? – SteeveDroz

+0

這是一種壞事 - 有形式的形式。並非所有的瀏覽器都能處理這個問題。他們中的一些人,將只是抹去其中一人 – xAqweRx

+0

@xAqweRx我明白,而且我知道,但我不能沒有它,這是我的上級要求的:/ – Erlaunis

回答

相關問題