I have a select box element with id myselect. The select box is in a form called myform. I am sure it is in this form because printing this before where my error is happening prints the correct form:
>> console.log(document.forms[0].id);
myform
I get the error:
Uncaught TypeError: Cannot read property 'myselect' of undefined (anonymous function)
where I do this:
document.myform.myselect
Any ideas why?
Thank you :).
Access the form as a property of
document.forms, notdocument:You can avoid falling into the traps of implied globals and properties in the future by just using
document.getElementById():