admin管理员组

文章数量:1425891

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.

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.

Share Improve this question asked Apr 15, 2011 at 12:15 Steve FischerSteve Fischer 3251 gold badge5 silver badges15 bronze badges 3
  • 1 clone() seems to work fine: jsfiddle/fkling/te3LX Maybe you should post your code too. – Felix Kling Commented Apr 15, 2011 at 12:18
  • Correction: It seems only to work for input elements. – Felix Kling Commented Apr 15, 2011 at 12:34
  • ahh ok. bennadel./blog/… i started with this. maybe it will help – Steve Fischer Commented Apr 15, 2011 at 12:36
Add a ment  | 

2 Answers 2

Reset to default 3

Edit: Post your code for creating the popup.

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

$('#myForm :input').each(function() {
    $(this).clone().appendTo('#newForm').val($(this).val());
});

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" />

本文标签: javascriptclone html form WITH valuesStack Overflow