473,385 Members | 2,014 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,385 software developers and data experts.

input[] array validation

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
2 22113


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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: The Plankmeister | last post by:
Hi... What's the best method of validating input characters? I would like to prevent users submitting exotic characters (such as those acquired on Windows Systems by pressing ALT+) and thought...
4
by: Gleep | last post by:
Hi PHP coders, I've got an issue I'm stuck with. Imagine there is a large form that has 5 columns and 20 rows. In each row there is a check box - then 4 input fields. I already have the code...
4
by: Martin Lucas-Smith | last post by:
I am wanting to know whether are XHTML1-valid characters for use within an id attribute and/or a name attribute. ...
12
by: Susan Cranford | last post by:
Please forgive, I have looked at so much info I can't figure out how to put it together even though I know it must be fairly simple. I have an array of input text boxes (txtDOBn) where n is...
14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
1
by: John Slate | last post by:
I have built a simple form that uses input validation. I use the EnableClientScript option to produce a javascript alert box when input errors occur. The only validation is a password confirmation...
17
by: Kermit Piper | last post by:
Hello, I have been searching, Googling, searching. Cannot find a javascript to calc 10, 11 or 12 digit UPC codes. I just need an algorithm that calcs to verify the correct check digit. I have...
8
by: Phil Latio | last post by:
I've been creating an application over the last few weeks and generally pleased with what I have produced but one area is irritating me, form validation. At the moment the forms are simply...
18
vikas251074
by: vikas251074 | last post by:
I am using ASP In my company, all employees have to sent materials out of premises. Any employee who need to sent material out will use this web application. In the first page, an employee enters...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.