【发布时间】:2015-09-15 21:17:27
【问题描述】:
我有一个包含 40 行的表。 我需要修复我的代码,以便最初应该出现一行,并且在行的末尾我需要一个按钮来显示下一行等等。
目前我的代码如下所示:
<table align="center" id="dataTable" border=1>
<tr class="header">
<th class='text ce6'><Strong>Product Code</Strong></th>
<th class='text ce6'><Strong>Desc</Strong></th>
<th class='text ce6'><Strong>Qty</Strong></th>
<th class='text ce6'><Strong>Unit</Strong></th>
<?php
for ($i = 1 ; $i < 40 ; $i++)
{ //Loop the table
echo "<select type='select' name='ProductCode";
echo $i;
echo "' id ='ProductCodee' size='1' onchange='GetDesc(this)'> ";
echo "<option value=''>-Select Type-</option>";
for($x = 0; $x<=40; $x++)
{
echo "<option value='";
echo $arrProducts[$x+1];
echo "'>";
echo $arrProducts[$x];
echo "</option>";
$x = $x + 2;
}
echo"</select>";
?>
<td><input size=25 type="text" id="desc" readonly=true/></td>
<td><input size=5 type="number" id="qty" /></td>
<td><input size=5 type="text" id="unit" readonly=true/></td>
<td><INPUT type="button" value="Add Row" onclick="addRow('dataTable')" /</td>
<?php
}
?>
【问题讨论】:
-
你真的要强制用户点击 40 次吗?
-
No @e4c5 它是可选的,无论他选择什么,都将是发布的行。
-
@AhmedAli 所以这个想法是在用户点击时只添加一行,但最大值应该是 40?
-
没错,40 是最大值,用户可以添加任何他想要的行。
-
我真的看不出问题/错误在哪里?还是您认为我们是来为您编写代码的?
标签: javascript php html