views:

152

answers:

1

Hey,

I am hiding a TextBoxin my aspx page like this:

myField.visible=false;

Now I have a DropDown as well which tries to access the TextBox on IndexChange. The problem is, it cant access the hiffen TextBox and I am getting document.form[0] is Null or Not an Object. How can I solve that? Is the some check for that in JavaScript?

Thanks :-)

A: 

If you are trying to access the first form in the document via its numerical index (hint: You shouldn't be, the id attribute is very handy, then you are looking for the first in a group of forms, not the first in a group of form.

document.forms[0] // It is plural
David Dorward
The is JavaScript added to the DropDown control which is called each time the index changed. The JS code tries to get the value from the text box like this:*document.forms[0].ctl00_Content_TX_myField.value*Here it throws the error.
grady
Err, so the code you put in the question is wrong, and my answer would correct it, and you've downvoted this answer because of that?
David Dorward
I didnt mean to downvote, was an accident...I am sorry!
grady
If your code says `document.forms` then your error message would not say `document.form`
David Dorward