Form Is Undefined Javascript Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site document.form.name.value in javascript About Us Learn more about Stack Overflow the company Business Learn more about document.aspnetform is undefined hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join typeerror document.forms 0 .elements is undefined the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Typeerror: Undefined form element document form1 is undefined asp net in FireFox only up vote 4 down vote favorite For some reason I am getting an error in FireFox only: Typeerror: document.forms.myCity.optionname is undefined The script works in all the other browsers: function WriteCookie() { document.cookie = "city" + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'; cookievalue = document.forms['myCity'].optionname.value + ";"; document.cookie='city='+cookievalue +'; expires=Fri, 3 Aug 2021 20:47:11 UTC; path=/'; window.location.href = "http://mywebsite.com"; } This
Document.forms[1] Is Undefined
script is in the header and is executed by this form:
The error is only in FireFox, any ideas? javascript firefox share|improve this question edited May 31 '14 at 0:43 JakeGould 16.7k62851 asked May 31 '14 at 0:10 Tara Samons 82112 1 I'm assuming you miscopied the TypeError message, right? (document, not doucment.) –Qantas 94 Heavy May 31 '14 at 0:20 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted Your error is this: Typeerror: document.forms.myCity.optionname is undefined I believe the issue is in this element: