Everything in onsubmit handler is undefined!!!

Discussion in 'JavaScript' started by Wylbur, Nov 21, 2008.

  1. #1
    Hi All;

    I'm instantiating an object, then trying to use the function defined
    within the object as a submit handler for the page/form. The handler
    ("val_obj.js_onsubmit_hndl") does indeed get called, but everything
    in it is undefined - including the reference parameter to the event
    object that should be passed when onsubmit is fired.

    This is the most recent version of my code:
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    <script type="text/javascript"><!--

    function the_obj_def ()
    {
    this.val1 = 3;
    alert ("this.val1 = " + this.val1);

    this.js_onsubmit_hndl
    = function onsubmit_hndl (the_event)
    {
    alert ("onsubmit: this.val1 = " + this.val1);

    if (the_event == undefined)
    alert ("the_event == undefined");
    else if (the_event == null)
    alert ("the_event == null");

    if (undefined == the_event) return;

    val1 = val1 + 1;

    alert ("val1 = " + val1);
    }
    }


    var val_obj = new the_obj_def ();

    alert ("After new object: val_obj.val1 = "
    + val_obj.val1);

    var the_form = document.forms["Form_01"];
    the_form.onsubmit = val_obj.js_onsubmit_hndl;

    // --></script>

    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



    Can anyone give this poor fool a clue?


    THANKS!!!

    Wylbur
    ======================
     
    Wylbur, Nov 21, 2008 IP
  2. Wylbur

    Wylbur Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    UPDATE: This issue has been resolved.
     
    Wylbur, Nov 21, 2008 IP