I have a working select box inside a table.
<tr>
<td>
<select name="type" class="inputbox input_table2 table2_index_4" id="item_type">
<?php foreach ($item_type as $type) { ?>
<option value="<?php echo $type->id ?>"><?php echo $type->name ?></option>
<?php } ?>
</select>
</td>
</tr>
And here is my scenario My table rows are appended with on trigger a button So how can code this loop in jQuery
I am very beginner in JavaScript libraries and here is what i am trying in JQuery
<?php
$addtablerow = '
$(document).on("click",".add_row_button",function(e) {
e.preventDefault();
var add_new_row = "<tr class=\'row\'> \
<td><select name=\'type\' id=\'item_type\' class=\'item_type\'> \
<?php foreach ($item_type as $type) { ?> \
<option vlaue=\'<?php echo $type->id ?>\'> <?php echo $type->name ?> </option> \
<?php } ?> \
</select> \
</td> \
</tr>";
$("table#item_type tbody").append(add_new_row);
indexassigner();
});
';
$this->registerJs($addtablerow, View::POS_READY);
?>
Thanks