$('#copy_button').click(function(){ copyFormValues( $('#form1'), $('#form2') ); }); function copyFormValues ( $source_form, $target_form ) { $source_form.find(':input').each(function(){ var field_name = $(this).attr('name'), field_value = $(this).val(); $target_form.find('[name='+field_name+']').val(field_value); }); }