javascript - copy select element in a table -



javascript - copy select element in a table -

i have dynamic table add together rows dynamically when user clicks button.

my button phone call next function :

<input type="button" value="add" onclick="addrowtuy($('#amonttabletuy tbody'), 'amonttuy');" />

my function adds new rows table. include text fields, inputs , select.

i have no problem creation of new inputs , text, select, want re-create existing select , alter id. that's problem.

this function create new rows in table:

function addrowtuy(table, value) { var nbrow = table.children().size(); table.append( "<tr>"+ "<td>"+(nbrow+1)+"</td>"+ "<td><input id='"+value+(nbrow+1)+"diam"+"'/></td>"+ "<td><input id='"+value+(nbrow+1)+"long"+"'/></td>"+ "<td>"+$("#amonttuy1type")+"</td>"+ //this want re-create select element "<td><input id='"+value+(nbrow+1)+"rugo"+"'/></td>"+ "</tr>"); }

have thought on way this?

something should work

"<td>"+$("#amonttuy1type").clone().attr('id', 'newid').html() +

you need clone , add together html string, not element itself. or create td element , append clone it.

update:

yeah, you're right, html() takes options, not select itself. seek this:

"<td>"+"<select id='newid'>" + $("#amonttuy1type").html() + "</select>" +

javascript jquery html

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -