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);
});
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
by the way, the destination form has a target that is set to an iframe (not a different domain)
Simply register an input even handler with the source textfield and copy the value to the target textfield .
Simply make a selection of fields and press the 'Copy to form' button at the top of the page. You'll be prompted to selected the destination form you'd like to copy the selected fields to. Make your selection and you're done!
Sometimes we need to set a default value of the <input> element, This example explains methods to do so. This property set/return the value of value attribute of a text field. The value property contains the default value, the value a user types or a value set by a script.
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); });
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)); });
If you need to copy the file from one input to another, you could use the below method.
$(".inputfield2")[0].files = $(".inputfield1")[0].files;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With