Why am I getting Javascript (form) or (this.form) errors?

Mar 24, 2007 24 Replies

In an existing, tested and working program, I have a form entry that simplifies to...


and a button of...


One of the things the setAmplitude function does is calculate a p1s value and then does a...



form.fp1s.value = p1s ;



This seems to work fine. I wanted to add a new feature to the program by adding a new button of


An initial function for imProveX was...



function imProveX (form) { setAmplitude (this.form) ; } ;



This should be doing the same thing the other button does, except from within a new proc instead of a button click. Instaad, an error of ...



'fp1s' is null or not an object



gets returned.



What am I doing wrong?



The full code appears as

formatting link



Many thanks, Don Lancaster voice phone: (928)428-4073 Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552 rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com Please visit my GURU\'s LAIR web site at http://www.tinaja.com

On Sat, 24 Mar 2007 08:51:19 -0700, Don Lancaster Gave us:

Depends on what version of java you have, and what you are developing scripts under, and their co-compatibilities.

JavaScript 1.1 being developed with Adobe GoLive 5.0.

Many thanks, Don Lancaster voice phone: (928)428-4073 Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552 rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com Please visit my GURU's LAIR web site at http://www.tinaja.com

here this refers to the imProveX function and there is no form property for function. pass the argument to setAmplitude function and all should be fine.

function imProveX (form) { setAmplitude (form) ;

??????????????

Try:

function imProveX (form) { setAmplitude (form) ; }

MassivePr> Depends on what version of java you have,

One of you two has no idea what he is talking about. "JavaScript: The World's Most Misunderstood Programming Language" by Douglas Crockford http://66.102.9.104/search?q=cache:gPOJH3E6QSkJ:

formatting link
*-*+zzz+ECMAScript+originally.called+Nearly-all-of-the-books-about-JavaScript-are-*-awful+*-*-its-share-of-design-errors+*-*-*-earlier-implementations-*-*-were-*-buggy+*-*-*-*-*-*-buggy-*-browsers

Don Lancaster a écrit :

function imProveX(form) { setAmplitude( form ); } this.form is already here ------^ and was called in button

To avoid mistakes try to do not use variables named as elements

function imProveX ( something ) { setAmplitude( something ); } or function imProveX ( aForm ) { setAmplitude( aForm ); }

it would have to be : 'form.p1s' is null or not an object

Stephane Moriaux et son (moins) vieux Mac déjà dépassé Stephane Moriaux and his (less) old Mac already out of date

MassiveProng said the following on 3/24/2007 12:05 PM:

The this above refers to the function and as such has no property named "form". If you want to pass it, simply pass the parameter form.

Has nothing to do with any of that.

Randy Chance Favors The Prepared Mind comp.lang.javascript FAQ - http://jibbering.com/faq/index.html Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

I see MicroBrain is metastasizing. =:-O

Cheers! Rich

There is a JavaScript NG and the posters there are *extremely* helpful.

No, it references the global object.

The only way imProveX's this keyword can refer to the imProveX function is if the calling function had set it that way using call or apply methods, and it doesn't. imProvex is called as a method of window, effectively as window.imProvex(). Therefore its this keyword references the window (global) object.

for the global object (unless one has been created elsewhere).

That should do it.

-- Rob

Thanks for the info.

btw, randy said the same thing :)

Yup.. if you add the missing brace.

Inside this function, 'this.form' is undefined. I think you need to pass 'form' to setAmplitude.

Because its null (not defined in the calling function imProveX.

Paul Hovnanian mailto:Paul@Hovnanian.com ------------------------------------------------------------------ The ark was skippered by amateurs, the Titanic was skippered by professionals.

Many thanks to everyone. Using (form) rather than (this.form) did it.

Presently exploring how to get this code to converge faster. Preferably instantly. Any suggestions?

Latest working version is

formatting link

Many thanks, Don Lancaster voice phone: (928)428-4073 Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552 rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com Please visit my GURU's LAIR web site at http://www.tinaja.com

"Classic Wrong" doesn't know the difference between "Java"" and "Javascript". :(

Service to my country? Been there, Done that, and I\'ve got my DD214 to prove it. Member of DAV #85. Michael A. Terrell Central Florida

I see c.l.j isn't the only group with an idiot. Are you related to VK by chance? Genetics might explain it.

Randy Chance Favors The Prepared Mind comp.lang.javascript FAQ - http://jibbering.com/faq/index.html Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Find a way to make a crude guess that is not too far off and use binary search (but i assume you already knew that. If the crude guess is fairly close, maybe use Taylors series on (1+error)?

Don Lancaster said the following on 3/25/2007 12:21 AM:

If by converging you mean execution speed, I didn't play very much but I was getting pretty instant results from the button clicks. You could remove some of the eval calls (I think there were 88 of them) where a lot of them appear to simply be eval'ing a string to convert it to a number. You could also look into some of the functions where you are referencing document.formName.elementName.value repeatedly with multiple elements. By storing a reference to document.formName you could speed up the look up time. In the reportToForm function you have lines like this:

document.mainform.fh07.value = fixFloat (h07, numPoints) ;

If, at the beginning of reportToForm you had a statement like this:

theForm = document.mainform;

Then you could change your references to this:

theForm.fh07.value

Which would pick up some speed gains.

After that, there are some other things I noticed in functions like hiHarm it appears you are doing some calculations and then calling another function. Are the p## variables changing each time you are calling that function? If not, move them outside the function and you don't have to repeatedly calculate them.

Randy Chance Favors The Prepared Mind comp.lang.javascript FAQ - http://jibbering.com/faq/index.html Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Been there, done that.

The series polynomials are very high order.

Many thanks, Don Lancaster voice phone: (928)428-4073 Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552 rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com Please visit my GURU's LAIR web site at http://www.tinaja.com

No, the JavaScript execution speed is not the immediate goal. But thanks for the tips.

The present goal is to find a fully deterministic solution to magic sinewave angles in a single step, rather than needing as many as five repeat (but remarkably fast converging) iterations.

Using JavaScript exploration to find (or prove not) an underlying algorithm.

Until recently, there was no reason to even suspect a deterministic solution equal to Magic Sinewave angles and Newton's method existed at all. 14x14 equations of multiple angle trig polynomials to the 28th power would not appear to offer trivial solutions. Chebycheff notwithstanding.

At present, Newton's Method works so extremely well that it strongly suggests a determnistic solution can be found. Finding one greatly simplifies extension to other numbers of pulses per quadrant.

And is the "missing link" to a totally solid Magic Sinewave theory.

Speed can come later. Speed is not an issue when zeroing out a few dozen low harmonics. Eventually the system can zero THOUSANDS of harmonics leading to a stunningly efficient means of digital sinewave generation.

Calculation time currently goes up with the third or fourth power of the number of harmonics zeroed.

See

formatting link
for a tutorial and the underlying equation set to be solved.

Many thanks, Don Lancaster voice phone: (928)428-4073 Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552 rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com Please visit my GURU's LAIR web site at http://www.tinaja.com

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required