将一个表单的文件输入字段的值复制到另一个表单的输入字段 [英] copying the value of a form's file input field to another form's input field

查看:16
本文介绍了将一个表单的文件输入字段的值复制到另一个表单的输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有两个表单,都有一个文件类型输入字段,我试过了

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

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

但是它没有被正确复制并且firebug在错误控制台中抱怨安全错误"

but then it doesn't get copied properly and firebug complains about "Security Error" in the error console

我做错了什么,如何正确复制文件输入字段的值

what did I do wrong and how can I properly copy the value of a file input field

顺便说一下,目标表单的目标设置为 iframe(不是不同的域)

by the way, the destination form has a target that is set to an iframe (not a different domain)

推荐答案

您不能将一个文件输入的值移动到另一个文件.相反,克隆输入,将克隆放置在原始位置,并将原始移动到隐藏表单中.

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);
});

这篇关于将一个表单的文件输入字段的值复制到另一个表单的输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆