【发布时间】:2014-05-10 07:38:58
【问题描述】:
我有一个选择选项。当用户选择我想将该行附加到表中的选项时。例如,如果用户选择 2,那么我想向表中添加 2 行,但我的行没有显示出来。
<script src="http://code.jquery.com/jquery-2.1.0.js"></script>
<p><strong>Select No of Activites You Want To Fill Up:</strong>
<select id="noAct">
<option value="1>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<table class="table table-bordered" id="tables">
<tr>
<th>SN</th>
<th>Activity Description</th>
<th>Unit</th>
<th>Weightage</th>
<th>100</th>
<th>75</th>
<th>50</th>
<th><50</th>
</tr>
</table>
<script>
function displayTable()
{
var value = $("#noAct").val();
$("#tables").empty();
//for loop to display the no of tables required
for ( var i=0; i < value; i++ )
{
//display the table
$("#tables").append("<tr>
<td>1</td>
<td>Web Site</td>
<td>Time</td>
<td>20</td>
<td>1 days</td>
<td>2 days</td>
<td>3 days</td>
<td>4 days</td>
</tr>
");
}
}
$( "select" ).change( displayTable );
displayTable();
</script>
【问题讨论】:
标签: jquery select html-table row