Having a form like this:
[code=html]<form name=”imageform”>
<input id=”image1″ type=”file” name=”file[]” value=”” />
<input id=”image2″ type=”file” name=”file[]” value=”” />
…
<input id=”image10″ type=”file” name=”file[]” value=”” />
</form>
when I capture the dispatch of the form and try to get the value of any of these file fields:
[code=php]var form = document.forms[‘imageform’];
for (var i = 0; i < form.file.length; i++) {
if (form.file.value != ”) {
// check valid type of file ….
}
}
There’s a Javascript error saying that form.file is undefined. It’s strange because I see in Firebug that “file” actually exists as a property of “form”. The same happens if I get rid of the temporary variable “form” and I do it this way:
document.forms[‘imageform’].file
or
document.forms.imageform.file
So, I eventually had to use the getElementById(‘image’ + i) method in order to do what I wanted. But there must be a “natural” way to get a value from an array defined in a form.
Any help is welcome.