Connect with us

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

Discussion in 'Electronic Design' started by Don Lancaster, Mar 24, 2007.

Scroll to continue with content
  1. 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:

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

    MassiveProng Guest


    Depends on what version of java you have, and what you are developing
    scripts under, and their co-compatibilities.
     
  3. 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:

    Please visit my GURU's LAIR web site at http://www.tinaja.com
     
  4. 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) ;


    ??????????????
     
  5. Andrew Holme

    Andrew Holme Guest


    Try:

    function imProveX (form) { setAmplitude (form) ; }
     
  6. MassiveProng

    MassiveProng Guest


    Could also relate to the runtime engine you are trying to run it
    under.
     
  7. JeffM

    JeffM Guest

  8. ASM

    ASM Guest

    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
     
  9. Randy Webb

    Randy Webb Guest

    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.
     
  10. Randy Webb

    Randy Webb Guest

    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"
     
  11. Rich Grise

    Rich Grise Guest

    I see MicroBrain is metastasizing. =:-O

    Cheers!
    Rich
     
  12. MassiveProng

    MassiveProng Guest


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

    MassiveProng Guest


    You're an idiot, GriseTard. What now... a stalking idiot as well?
     
  14. Robert Baer

    Robert Baer Guest

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

    RobG Guest

    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.
     
  16. Thanks for the info.

    btw, randy said the same thing :)

    Yup.. if you add the missing brace.
     
  17. 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.
     
  18. 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:

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

  19. "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
     
  20. Randy Webb

    Randy Webb Guest

    Rich Grise said the following on 3/24/2007 5:25 PM:
    I see c.l.j isn't the only group with an idiot. Are you related to VK by
    chance? Genetics might explain it.
     
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 (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-