Avatar of Wanting2LearnMan
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Add dropdown box to html table using javascript help

I have a custom javascript handler that when a button is pressed it appends a row to a html table like so:
            '<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>'+

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

JavaScriptHTMLWeb Development

Avatar of undefined
Last Comment

8/22/2022 - Mon
Anuradha Goli

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Excellent thanks :)

I have another question related to this appearing soon.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck