Jump to content

How Can I Obtain Form.lenght When There Is An Input Called Lenght?


urganda
 Share

Recommended Posts

I want to recurse all elements of a form and display its value on an alert box. I could use

for (g==0;g<form.lenght;g++){  window.alert(form.elements[g].value);}

But I have a problem. Some forms have an element called lenght, so I can't use my code with these forms.What do you suggest me?

Link to comment
Share on other sites

Also, in the for loop only use one = when you initialize the iterator.
The "==" in the iterator was a typo made when copying code here. That typo is not in my original script."lenght" for "length" was another typo. I always test the correct spelling of that particular word when writing a script, but I don't when writing in a forum.You can see the full script at my blog. It is intended as an IE link that shows up the forms and inputs in a page, in order to avoid the need of GreaseMonkey. But it breaks when some input box is called "length".I've tried form.elements.length, form.elements[].length and almost any variation.I've also tried "for f in form.elements", but it shows up all properties of elements (including both dtd properties and input boxes).
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...