Copy File Field Value to Dynamic File Field Value

D

Darko

The solution is ready! As genius, as simple... May not be the most
perfect but may work for me fine.
So, instead of copying or cloning, I'd just use that object itself and
append it to a new form:

<input onchange="doit(this)">
function doit(obj){
var go = new dothat(obj);}

function dothat(obj){
//code is a sample........
var input = obj
this.form = document.createElemet("form")
this.form.appendChild(input)
//...........
this.form.submit()

}

Note: the input disappears from the page, but I would hide it anyway
because I do not need it. I can replace with loading progress image
and then a link when the file is uploaded.
What do you think? Would this cause any issues?
Thanks

I guess not. I like it. It's just not acceptable in general, when one
doesn't want it to disappear from
the page, but in cases where you'd hide it anyway, which is the
majority I think, it should work.

Indeed it is simple, and indeed we didn't think of it (maybe because
we didn't presume you wouldn't mind
it disappear, so it was subconsciously excluded from the list of
available ideas). Good work.
 
S

s0lnic

VUNETdotUS said:
The solution is ready! As genius, as simple... May not be the most
perfect but may work for me fine.
So, instead of copying or cloning, I'd just use that object itself and
append it to a new form:

<input onchange="doit(this)">
function doit(obj){
var go = new dothat(obj);
}
function dothat(obj){
//code is a sample........
var input = obj
this.form = document.createElemet("form")
this.form.appendChild(input)
//...........
this.form.submit()
}

Note: the input disappears from the page, but I would hide it anyway
because I do not need it. I can replace with loading progress image
and then a link when the file is uploaded.
What do you think? Would this cause any issues?

Yeah, I did almost the same thing in one application some time ago which
works great. The only difference is that I was appending a fieldset which
contains multiple file inputs to a new form. It works very well :)
 
S

s0lnic

VUNETdotUS said:
do you mean I have to submit the original for and then repaint it
plugging all values in? I do not know really...

In case you have other fields in that form, not only file inputs, then
submitting the original form doesn't make any sense of course. Your
solution with appending file inputs to a new form is far better then what
I've suggested.
 
T

Thomas 'PointedEars' Lahn

s0lnic said:
Oh, so submit the form and dynamically create a new one...user won't see
anything, don't worry. This method works on every major browser.

Unless, of course, for some reason either client-side script support or
sufficient DOM support is not available.

Bad idea.


PointedEars
 
D

Darko

Unless, of course, for some reason either client-side script support or
sufficient DOM support is not available.

Bad idea.

PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

Unless he's got lynx :)
 
T

Thomas 'PointedEars' Lahn

Darko said:
s0lnic said:
VUNETdotUS wrote:
I need it to upload the files without refreshing the page. So, my new
hidden, dynamically created DOM form is submitting file value to iframe
and user keeps on working with current visible form.
Oh, so submit the form and dynamically create a new one...user won't see
anything, don't worry. This method works on every major browser.
Unless, of course, for some reason either client-side script support or
sufficient DOM support is not available.

Bad idea.
[...]

Unless he's got lynx :)

This is by far not the only one possibility for that.

Please trim your quotes, see
http://www.jibbering.com/faq/faq_notes/clj_posts.html


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top