copying the value of a form's file input field to another form's input field

前端 未结 2 1924
刺人心
刺人心 2020-12-03 04:22

So I have two forms, both have a file type input field and I tried

$(\'.inputfield1\').change(function(){
   var file = $(this).val();
   $(\'.inputfield2\')         


        
相关标签:
2条回答
  • 2020-12-03 05:07

    You can't move the value of one file input to another. Instead, clone the input, place the clone where the original is, and move the original into the hidden form.

    $(".inputfield1").change(function(){
      var $this = $(this), $clone = $this.clone();
      $this.after($clone).appendTo(hiddenform);
    });
    
    0 讨论(0)
  • 2020-12-03 05:20

    I know it is a late answer, but I had a similar problem that I just figured out today.

    What I did was move the File input to the new location after deleting the current one in the other location. By moving the element, everything stayed intact on all my tests.

    $('.inputfield1').change(function() {
      $('.otherinputfield').remove();
      $('#newform').append($(this));
    });
    
    0 讨论(0)
提交回复
热议问题