Forum Moderators: open
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$(function(){
$(".add-input").live('click',function(){
button = $(this);
section = button.parents('.section:first');
titleInput = section.find('input.title:first').clone();
button.before( titleInput.val('') );
});
$(".add-section").live('click',function(){
button = $(this);
section = $('.section:first').clone();
$(':input',section).each(function(){ this.value = this.defaultValue; });
button.before( section );
});
});
</script>
<p class='section'>
<label>Hello!</label>
<select class='location'><option>I'm a dummy!</option><option>I'm a dummy!</option></select>
<input type='text' name='title[]' class='title' />
<button class='add-input'>Add an input</button>
</p>
<button class='add-section'>Add a section</button>