Solved

setting a property that has only a getter

Posted on 2008-10-06
5
867 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22653052
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
ID: 22653232
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
ID: 22653829
>>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
ID: 31503544
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
ID: 22654269
>>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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

707 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