473,324 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

dynamic file input controls

J.R
Greetings,

I'm adding dynamically created input type='file' controls via JavaScript.
However when I try to access they do not seem to be returned in the form
collection. Any ideas?

Thanks, John.
Jul 20 '05 #1
2 6919
VK
You cannot set/access file properties from JavaScript : the access is locked
for security reasons.
J.R <so*****@somewhere.com> wrote in message
news:Y7abb.4118$I36.3840@pd7tw3no...
Greetings,

I'm adding dynamically created input type='file' controls via JavaScript.
However when I try to access they do not seem to be returned in the form
collection. Any ideas?

Thanks, John.

Jul 20 '05 #2
Ivo
"J.R" <so*****@somewhere.com> wrote in message
news:Y7abb.4118$I36.3840@pd7tw3no...
Greetings,

I'm adding dynamically created input type='file' controls via JavaScript.
However when I try to access they do not seem to be returned in the form
collection. Any ideas?
Thanks, John.


Are you sure they have unique names, or if not, unique indeces in an array?
Here is what I use, more or less directly copied from the page so it is not
tailored to the question:

<script type=text/javascript>
function add(n){
curdiv=document.activeElement.previousSibling;
newdiv=curdiv.cloneNode(true);
curdiv.insertAdjacentElement("afterEnd",newdiv);
}
</script>

<form method=post enctype="multipart/form-data" action="/script.htm">
<input type=hidden name=MAX_FILE_SIZE value=3000000>
<div>File: <input type=file name=userfile[]></div>
<input class=button type=button value="Add" onclick=add(this) ><br>
<input class=button type=submit value=" Upload ">
</form>
There are several forms on this page, each with their own "Add" button, and
in the case of the upload form with the <input type=file>,
activeElement.previousSibling (not sure if this is IE only) is the div
containing both the input and its label. Note the input name is a member of
an array because of the square brackets. This ensures the server script that
receives the form submission will see all inputs, regardless of how many
times I clicked "Add"!

HTH
Ivo
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Roy Lawson | last post by:
I want to enable the user to define parts of their user interface. I am developing an application that does some accounting functions (basicly the end user enters revenues for each account, and...
3
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
1
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
7
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the...
4
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just...
0
by: Venus | last post by:
Hello, After trying some ways to do it I wanted to use something like the code below but for some reason is not working (I have to generate the entire form dynamically (not only the controls)):...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
4
by: Bhavin | last post by:
How can I capture user entered values from dynamically created controls in ASP.NET ? Thanks,
2
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.