SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    auto submit form

    I'm using the following code in a php page directly behind the closing form tag. But I get an error saying "object doesn't support this property or method"

    Does anyone know why? If I remove this script and just click the form's button everything works fine.

    <SCRIPT LANGUAGE="Javascript">
    <!--
    document.forms("form1").submit()
    //--></SCRIPT>

  2. #2
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try a semi-colon at the end.... but i woudnt even bother....
    thats is a security risk, so the browser probably wont let you do it anyway...
    James Rice :: Ex-Mentor
    www.jamesrice.net

  3. #3
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It does work if you change your () to [] ...
    Code:
    <SCRIPT LANGUAGE="Javascript">
    <!--
    document.forms["form1"].submit()
    //--></SCRIPT>
    the only thing is that it does not seem to trigger the onsubmit event ?
    but it can be solved like this:
    Code:
    <SCRIPT LANGUAGE="Javascript">
    <!--
    document.forms["form1"].submit()
    document.forms["form1"].onsubmit()
    //--></SCRIPT>

  4. #4
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried it out but still doesn't work. Is there anything else I can try. The form uses "POST". Does that make any difference?

  5. #5
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try putting an id in the submit button and calling:

    Code:
    document.getElementById('subbutn').click()

  6. #6
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE wont let you fake a submit like that... it gives a security error....
    at least it did last time i checked
    James Rice :: Ex-Mentor
    www.jamesrice.net

  7. #7
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe if you gave us some explanation of what it is you're trying to do here. Do you want the form to submit as soon as the page loads??

  8. #8
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Code:
    onload = function ()
    {
    document.forms["form1"].submit();
    }

  9. #9
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    JR=> what version of IE have you tested it on ...
    I've been doing teste with IE6 (no SP) and previous code works...
    may be recent SP has blocked this possibility ?

  10. #10
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im using IE6 with SP2...
    I didnt test the code that was posted... but I was trying to this stuff a while back and IE kept giving security warnings...

    basically what i had been trying to do was replace both the file browse button and the submit button with images. I did it without a problem... but IE wouldnt let it submit when I was using two "fake" buttons...
    James Rice :: Ex-Mentor
    www.jamesrice.net


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
  •