Solved

setting a property that has only a getter

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Debugging step-by-step Jquery/Javascript 6 57
count download link and run update query 9 56
Animated .jpg? 13 60
How to change pointer icon to hand icon on mouseover 2 19
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. …
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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…

920 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

12 Experts available now in Live!

Get 1:1 Help Now