Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clone html form WITH values

I am trying to duplicate a form after it has been filled out. So the user fills out the form then hits submit. then a new window opens with the full html form, images, and styling included AND the values so they can print the filled out version. i tried .html() and .clone(). but neither seem to work.

any help is much apperciated. and please don't hesitate to ask questions.

like image 996
Steve Fischer Avatar asked Jun 12 '26 10:06

Steve Fischer


2 Answers

Edit: Post your code for creating the popup.

You may need to use val() to copy the values over. http://jsfiddle.net/Na6GN/2/

$('#myForm :input').each(function() {
    $(this).clone().appendTo('#newForm').val($(this).val());
});
like image 190
Calum Avatar answered Jun 13 '26 23:06

Calum


Its working fine:

JS:

$('btnclone').click(function() {
    var mywindow = window.open();
    $(mywindow.document.body).append($('form').eq(0).clone());
});

Html Code

<form>
    <input name='test' />
</form>

<input type="button" value="Clone" name="btnclone" id="btnclone" />
like image 44
Anand Thangappan Avatar answered Jun 14 '26 00:06

Anand Thangappan