Add delete icon to dynamically created <option>
Hi,
I have a <select> for industry which is by default one on the form and allowing user to create more using jquery
I want to include a delete icon beside the dynamically added <option>.
How can id do this?
- <tr>
- <td valign="middle">Industry</td>
- <td valign="middle">:</td>
- <td valign="middle">
- <div id="container">
- <select id="cboIndustry" name="cboIndustry[]" style="width: 100%" required>
- <option value="" selected>[Industry..]</option>
- <?php
- $mysql_command = "CALL sp_populate_industry()";
- $mysql_query = $mysql_connection->prepare($mysql_command);
- $mysql_query->execute();
- while($mysql_row = $mysql_query->fetch())
- {
- ?>
- <option value="<?php echo $mysql_row['industry_id']; ?>"><?php echo $mysql_row['industry_name']; ?></option>
- <?php } ?>
- </select>
- </div>
- </td>
- </tr>
- <script type="text/javascript">
- $(function() {
- var counter = 0;
- $('#add_industry').click(function() {
- counter++;
- var newField = $('#cboIndustry').clone().
- attr({id: 'cboIndustry_' + counter,
- name: 'cboIndustry[]'});
- $('#container').append(newField);
- });
- });
- </script>