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

D

Don Lancaster

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

<INPUT name ="fp1s" type="text" value=0.000 size=12 >

and a button of...

<input type="button" value=" Set Amplitude "
onclick="setAmplitude (this.form)">

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

<input type="button" value="Improve?" onclick="imProveX
(this.form)">

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 http://www.tinaja.com/demo28q.asp


--
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: (e-mail address removed)

Please visit my GURU's LAIR web site at http://www.tinaja.com
 
M

MassiveProng

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

<INPUT name ="fp1s" type="text" value=0.000 size=12 >

and a button of...

<input type="button" value=" Set Amplitude "
onclick="setAmplitude (this.form)">

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

<input type="button" value="Improve?" onclick="imProveX
(this.form)">

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 http://www.tinaja.com/demo28q.asp


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

Don Lancaster

MassiveProng said:
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: (e-mail address removed)

Please visit my GURU's LAIR web site at http://www.tinaja.com
 
S

scripts.contact

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) ;


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

??????????????
 
A

Andrew Holme

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

<INPUT name ="fp1s" type="text" value=0.000 size=12 >

and a button of...

<input type="button" value=" Set Amplitude "
onclick="setAmplitude (this.form)">

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

<input type="button" value="Improve?" onclick="imProveX
(this.form)">

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 http://www.tinaja.com/demo28q.asp


Try:

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

ASM

Don Lancaster a écrit :
<input type="button" value="Improve?" onclick="imProveX
(this.form)">

An initial function for imProveX was...

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

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 ); }
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

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

Rich Grise

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.

I see MicroBrain is metastasizing. =:-O

Cheers!
Rich
 
M

MassiveProng

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



No, it relates to scope issues of variables and has nothing to do with
any "runtime engine"


We had problems at work after upgrading to a new version. Just
thought I'd mention it. No big deal.
 
R

RobG

here this refers to the imProveX function

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.

and there is no form
property for function.

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

pass the argument to setAmplitude function and
all should be fine.

function imProveX (form) { setAmplitude (form) ;

That should do it.
 
P

Paul Hovnanian P.E.

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

<INPUT name ="fp1s" type="text" value=0.000 size=12 >

and a button of...

<input type="button" value=" Set Amplitude "
onclick="setAmplitude (this.form)">

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

<input type="button" value="Improve?" onclick="imProveX
(this.form)">

An initial function for imProveX was...

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

Inside this function, 'this.form' is undefined. I think you need to pass
'form' to setAmplitude.
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.

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

Don Lancaster

scripts.contact said:
Thanks for the info.

btw, randy said the same thing :)





Yup.. if you add the missing brace.

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 http://www.tinaja.com/demo28a.asp


--
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: (e-mail address removed)

Please visit my GURU's LAIR web site at http://www.tinaja.com
 
D

Don Lancaster

Robert said:
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)?

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: (e-mail address removed)

Please visit my GURU's LAIR web site at http://www.tinaja.com
 
D

Don Lancaster

Randy said:
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.


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 http://www.tinaja.com/glib/msinexec.pdf 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: (e-mail address removed)

Please visit my GURU's LAIR web site at http://www.tinaja.com
 
D

Dr J R Stockton

In comp.lang.javascript message <f0ja03d5kr35qjqll27vev1a84pponfdi4@4ax.
com>, Sat, 24 Mar 2007 09:05:21, MassiveProng <MassiveProng@thebaratthee
ndoftheuniverse.org> posted:
Depends on what version of java you have, and what you are developing
scripts under, and their co-compatibilities.

Feel free to contribute here in if you ever
have anything useful to say; but not otherwise.
 
P

Paul Hovnanian P.E.

Don said:
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 http://www.tinaja.com/demo28a.asp

I don't see any code there (a few busted links). What sort of algorithm
is it that you are trying to converge?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top