Retriving an array of all form

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
paolo
Forum Newbie
Posts: 15
Joined: Sat May 14, 2005 6:06 am

Retriving an array of all form

Post by paolo »

Hello,

I would like to know if there's a funcion or a simple way to retrieve an array of all forms field present in a form.
I've a form made of 20 field and want to reset all using a function instead of reset button; the reason is that the form can take parameters from session's variables but sometime I need to force the cleaning.For now I've done form.field1.value = "", form.field2.value = "" .... and so on bu since I would like to use that function for other forms I just ask myself if there's a way to take all the fields and then with a for cycle to clean them all.
Thanks
Paolo
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

paolo
Forum Newbie
Posts: 15
Joined: Sat May 14, 2005 6:06 am

Post by paolo »

I tryied to follow the example but the script doesn't work, it seems it's unable to get the lenght of items
alert(document.forms[0].elements.lenght ); gives a box with Undefined... anyone knows a possible reason?
Thanks
Paolo
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Moved to Client Side
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

try length instead of lenght
Post Reply