2010-08-20 108 views
0

我需要一個代碼,它根據下拉列表的選擇創建表格行。例如,如果我選擇3,那麼我需要3行來創建。我能夠動態地創建行,但在更改ddl值時,我無法刪除正在創建的以前的行。如何使用jquery或java腳本實現這一點。基於選擇的下拉列表創建錶行數

感謝薩加。

+0

爲什麼不顯示你的代碼。 – 2010-08-20 08:13:45

回答

0

所以,你只是想從表中刪除行,然後添加X數量的行呢?

你想要的是jQuery的remove方法:

// Get the table and delete the rows 
var $table = $("#tableId"); 
$table.find("tr").remove(); 

// Get the row count and create the number of rows 
var rowCount = GetYourRowCount(); 
for (var i = 0; i < rowCount; i++) 
{ 
    var $tr = $("<tr>"); 
    $table.append($tr); 
} 
+0

謝謝你的工作 – Sagar 2010-08-31 02:43:09