Solved

setting a property that has only a getter

Posted on 2008-10-06
5
864 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

726 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