Cloud Stack Ninja

I have a working select box inside a table.

        <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 } ?>

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


$addtablerow = '    
        $(document).on("click",".add_row_button",function(e) {           
            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> \ 
            $("table#item_type tbody").append(add_new_row);
$this->registerJs($addtablerow, View::POS_READY);


Read more here:

Content Attribution

This content was originally published by code-droid at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: