By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,238 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

input[] array validation

P: n/a
Hello...

I need to get the values (for validation) of a php style html input array:

<input type="file" name="image[]">
<input type="file" name="image[]">
<input type="file" name="image[]">
<input type="file" name="image[]">

The PHP faq gives an example:

variable = documents.forms[0].elements['var[]'];

http://ca3.php.net/manual/en/faq.htm...elect-multiple

But that doesn't actually work, for me.

What would be the proper way to loop through each of the upload inputs
and get the value?

Thanks,
-J
--
Jason Morehouse
Vendorama - The evolution of e-commerce
http://www.vendorama.com
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Jason Morehouse wrote:

I need to get the values (for validation) of a php style html input array:

<input type="file" name="image[]">
<input type="file" name="image[]">
<input type="file" name="image[]">
<input type="file" name="image[]">

The PHP faq gives an example:

variable = documents.forms[0].elements['var[]'];

http://ca3.php.net/manual/en/faq.htm...elect-multiple

But that doesn't actually work, for me.


Be more specific about what happens, do you get a script error?
The access to
document.forms[0].elements['image[]']
with those inputs above being inside of the first <form> on the page
should indeed yield a collection with a length property through which
you can loop.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

P: n/a
Jason Morehouse wrote:
Hello...

I need to get the values (for validation) of a php style html input array:

<input type="file" name="image[]">
<input type="file" name="image[]">
<input type="file" name="image[]">
<input type="file" name="image[]">

The PHP faq gives an example:

variable = documents.forms[0].elements['var[]'];

http://ca3.php.net/manual/en/faq.htm...elect-multiple

But that doesn't actually work, for me.

What would be the proper way to loop through each of the upload inputs
and get the value?


if(variableLength = documents.forms[0].elements['var[]'].length);

It's not a select-multiple, its type is file, but js should provide a
collection, try it.
Mick
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.