Add dropdown box to html table using javascript help

Wanting2LearnMan
Wanting2LearnMan used Ask the Experts™
on
I have a custom javascript handler that when a button is pressed it appends a row to a html table like so:
 $(table).append(
            '<tr><td><input  class="SettingsListField save_pending" type="text" ' +
            'id="' + $(this).attr('id') + '_' + newIndex + '" name="' + $(this).attr('id') + '"></td>'+
            '<td><input  class="SettingsListField save_pending" type="text" ' +
            'id="' + $(this).attr('id') + '_' + newIndex + '" name="' + $(this).attr('id') + '"></td>'+
            '<td><div class="SettingsIconContainer"><a class="InputListbtnRemove" onclick="return false;">'+
            '<img src="/static_media/img/RemoveButton2_small.png" alt="Remove address details" /></a></div></td>'+
            '<td><div class="SettingsStatusContainer" id="' + $(this).attr('id') + '_' + newIndex + '_status"></div></td>'+
            '</tr>'
            ); 

Open in new window


This is working fine.

Now I want to modify this so that adds a dropdown box and adds some items to this dropdown box.

SO I have added the following line
 '<td><select class="CustomSelect1 not_changed" id="' + $(this).attr('id') + '_' + newIndex + '" name="' + $(this).attr('id') + '" <option>"item1"</option>></td>'+

Open in new window


Now this adds the dropdown box but it does not iinsert the "item1" into it??

What am I doing wrong??

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Systems Development / Support Specialist
Commented:
you are not closing select before option tag starts ,add > before option tag
 '<td><select class="CustomSelect1 not_changed" id="' + $(this).attr('id') + '_' + newIndex + '" name="' + $(this).attr('id')
 + '"><option>"item1"</option>></td>'+

Open in new window

Author

Commented:
Excellent thanks :)

I have another question related to this appearing soon.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial