SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    None
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Document has no properties. FireFox.

    Hi,

    I'm using firefox browser and am having problems with the following code:

    Code:
     <form name="frmGate" action="somepage.php" method="post">
     <input type="hidden" name="pass" value="1">
     </form>
     
     <script language="JavaScript">
     document.forms['frmGate'].submit();
     </script>
    I get the following error:

    Error: document.forms.frmGate has no properties

    Now, if I get that code in between <body> tags, it works. But the page I have this code in can't have <body> tags. Anything else is fine.

    Please help.

  2. #2
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    frmGate hasn't yet been created by the time this script runs. move into a function and call that up during body onload, though, I feel I should ask, why are you submitting a form when the page loads?
    Last edited by rushiku; Aug 24, 2004 at 19:45.

  3. #3
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    None
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's no body tag, so onload won't work.

    This is for a payment system - after transaction is done it needs to submit the form.

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is one of those 'intermittent' issues, but it's likely the form object hasn't had time to 'set up' when that script statement runs. You're incorrect about onload, however, as it's actually window.onload (HTML uses the <body> tag as there's no <window> tag).
    Code:
    <form name="frmGate" action="somepage.php" method="post">
    <input type="hidden" name="pass" value="1">
    </form>
    <script type="text/javascript">
    
    onload = function()
    {
        document.forms[0].submit();
    }
    
    </script>
    ::: certified wild guess :::


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •