javascript - clone html form WITH values - Stack Overflow

I am trying to duplicate a form after it has been filled out. So the user fills out the form then hits

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745428394a4627282.html

相关推荐

  • javascript - clone html form WITH values - Stack Overflow

    I am trying to duplicate a form after it has been filled out. So the user fills out the form then hits

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信