Connecting Tech Pros Worldwide Forums | Help | Site Map

runtime error: object doesn't support this property or method

Matt
Guest
 
Posts: n/a
#1: Jul 23 '05
I tried to display all html control types in the form. But it has run
time error
"object doesn't support this property or method" on
document.write(obj.type);

Even I do document.write('hello world'); it still has the same error.
function clearForm()
{ var i=0;
for (i=0; i<InputForm.elements.length-1; i++)
{ var obj = InputForm.elements[i];
document.write(obj.type); //runtime error: object doesn't support
this property or method
}
}

any ideas?? thanks!!

Lee
Guest
 
Posts: n/a
#2: Jul 23 '05

re: runtime error: object doesn't support this property or method


Matt said:[color=blue]
>
>I tried to display all html control types in the form. But it has run
>time error
>"object doesn't support this property or method" on
>document.write(obj.type);
>
>Even I do document.write('hello world'); it still has the same error.
>function clearForm()
>{ var i=0;
> for (i=0; i<InputForm.elements.length-1; i++)
> { var obj = InputForm.elements[i];
> document.write(obj.type); //runtime error: object doesn't support
>this property or method
> }
>}[/color]

Don't use document.write() for debugging. As soon as you write
anything to a document that has already been displayed, you
clear the current contents. That means that on the second time
through the loop, your form is gone.

Use alert(), unless you have dozens of fields.

Also, your loop is missing the last form element. That may be
what you want if you know that the last element is your submit
button. Otherwise, your loop should be:
for(i=0; i<InputForm.elements.length; i++)

G Roydor
Guest
 
Posts: n/a
#3: Jul 23 '05

re: runtime error: object doesn't support this property or method


voir typeOf

http://msdn.microsoft.com/library/de...tBelongsTo.asp

Matt a écrit:[color=blue]
> I tried to display all html control types in the form. But it has run
> time error
> "object doesn't support this property or method" on
> document.write(obj.type);
>
> Even I do document.write('hello world'); it still has the same error.
> function clearForm()
> { var i=0;
> for (i=0; i<InputForm.elements.length-1; i++)
> { var obj = InputForm.elements[i];
> document.write(obj.type); //runtime error: object doesn't support
> this property or method
> }
> }
>
> any ideas?? thanks!![/color]

Lee
Guest
 
Posts: n/a
#4: Jul 23 '05

re: runtime error: object doesn't support this property or method


G Roydor said:[color=blue]
>
>voir typeOf
>
>http://msdn.microsoft.com/library/de...tBelongsTo.asp[/color]

No. He's trying to access the "type" field of form controls.

Closed Thread