Solved

setting a property that has only a getter

Posted on 2008-10-06
5
861 Views
Last Modified: 2012-05-05
I get the subject error message in FireFox error console.

I believe line 46 is either
ename = document.st.elements[i].name;
or
f2 = ename.substr(0,2);

What does this mean? I don't see a problem.


le = document.st.elements.length;	

			someok = false;

			for (i = 0; i < le; i++) {

				if (document.st.elements[i].type = "hidden") {

					ename = document.st.elements[i].name;

					f2 = ename.substr(0,2);

					if (f2 == "lu") {

						if (document.st.elements[i].value != "None") {

							luval = parseInt(document.st.elements[i].value);

							unitval = parseInt(document.st.selall.value);

							if (luval >= unitval) {

								someok = true;

								break;

							}

						}

					}

				}

			}

Open in new window

0
Comment
Question by:Richard Korts
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:hielo
Comment Utility
make sure your form tag has name="st" AND also make sure every input element has a name defined. If one of your fields does not have a name, this:
ename = document.st.elements[i].name;

will set ename to undefined and cause problems.
0
 

Author Comment

by:Richard Korts
Comment Utility
To hielo:

I gave names to all the elements, including the submit buttons. They were the only ones with no name.

It does the same thing.

Entire html file is attached (note the html is generated from php).
htmlsource.txt
0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
Comment Utility
>>if (document.st.elements[i].type = "hidden")
you nee TWO equal signs:
if (document.st.elements[i].type == "hidden")
0
 

Author Closing Comment

by:Richard Korts
Comment Utility
That one gets me EVERY time, in both php & JavaScript. For some reason, I can NEVER see those. So obvious, but so illusive.
0
 
LVL 82

Expert Comment

by:hielo
Comment Utility
>>That one gets me EVERY time
Then it's your responsibility to learn from your mistakes. If you always get something like this wrong:
if( x = 3 )

you will NEVER get it wrong if you invert them:
if( 3 = x )

a number and a string are "constants". You cannot assign something to a constant, so the compiler/interpreter will throw a runtime error if you omit that second = sign. At that point its obvious.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now