2010-08-20 111 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