i want to add table base on the input number it supposed to be like this: value=3
<input type="text" id="pila" name="pila" maxlength="2px" onchange="balhin()" value="3"/>
js function:
function balhin(){
var pila = $("#pila").val();
var a;
var i = 0;
while (i <= pila)
{
a .= "<tr><td>amew</td><td>amew</td><td>amew</td></tr>";
i++;
}
$(".pakita").append(a);
}
the html code:
<table id="tablesorter">
<thead>
<tr>
<th>#</th>
<th>Trip Number</th>
<th>NO. Boxes</th>
</tr>
</thead>
<tbody class="pakita"></tbody>
</table>
but the js function is not working? what would be the possible reason why its not working?
expected output:
<table id="tablesorter">
<thead>
<tr>
<th>#</th>
<th>Trip Number</th>
<th>NO. Boxes</th>
</tr>
</thead>
<tbody class="pakita">
<tr><td>amew</td><td>amew</td><td>amew</td></tr>
<tr><td>amew</td><td>amew</td><td>amew</td></tr>
<tr><td>amew</td><td>amew</td><td>amew</td></tr>
</tbody>
</table>
seems incorrect. javascript concatenation is done by +=
also initialize
a="" ;(empty string)