Copy Drop-down Lists When User Clicks Button In Javascript
How would I go about adding more drop down lists to a form, so when a user clicks a button a drop-down box will be added to the form? I'm guessing some sort of javascript? UPDATE:
Solution 1:
You can do this with .cloneNode()
.
Demo: http://jsfiddle.net/ThinkingStiff/pSEUH/
HTML:
<formid="form"><selectid="select"><option>one</option><option>two</option><option>three</option></select><buttonid="add">Add</button></form>
Script:
document.getElementById( 'add' ).addEventListener( 'click', function ( event ) {
event.preventDefault();
var select = document.getElementById( 'select' ).cloneNode( true );
document.getElementById( 'form' ).appendChild( select );
}, false );
Post a Comment for "Copy Drop-down Lists When User Clicks Button In Javascript"