Simple Javascript form problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • igraffman
    New Member
    • Feb 2008
    • 7

    Simple Javascript form problem

    What is wrong with this code that getval is not found?

    // This function opens the login window.

    [CODE=javascript]var loginWin;

    function getval ()
    {
    return true;
    document.write ("here I am");
    alert ("boo");
    }


    function login ()
    {

    loginWin = window.open ("", "EditLogin" , "width=20,heigh t=600,scrollbar s=yes,resizable =yes,toolbar=no ,location=no,di rectories=no,st atus=no,menubar =no,copyhistory =no");

    loginWin.resize To(300,200)

    loginWin.docume nt.write("here" );
    loginWin.docume nt.write('<form name="logform" action="" onSubmit="getva l()">');
    loginWin.docume nt.write('<labe l>Username</label><br/><input name="username"/><br/>');
    loginWin.docume nt.write('<labe l>Password</label><br/><input name="password" type="password"/><br/>');
    loginWin.docume nt.write('<inpu t type="submit" name="login" value="login">' );
    loginWin.docume nt.write('</form>');

    }[/CODE]

    Thanks
    Last edited by acoder; Feb 15 '08, 09:57 AM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Moved to the JavaScript forum. Please post your question in the appropriate forum.

    getval can't be found because it's in the parent page and the code calling it is in the child window. Use window.opener.g etval() to refer to it correctly.

    Comment

    • igraffman
      New Member
      • Feb 2008
      • 7

      #3
      You were right, of course! It works.

      Thanks so much!


      Originally posted by acoder
      Moved to the JavaScript forum. Please post your question in the appropriate forum.

      getval can't be found because it's in the parent page and the code calling it is in the child window. Use window.opener.g etval() to refer to it correctly.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You're welcome. Glad you got it working.

        Comment

        Working...