SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript, submit form

    Capturing the current form and calling submit fails with "object doesn't support this method or property." Whether calling this.form.submit() or various combinations. Anyone have any idea why this would fail?
    HTML Code:
     <form action="/ASX2/www/public/rankings.php" enctype="application/x-www-form-urlencoded"  name="formWrap" id="formWrap" method="post" >
     ...
     </form>
     
      document.forms['formWrap'].submit()
       document.getElementById('formWrap').submit()
     this.form.submit()

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think your script is in conflict somewhere else...
    try this submit somewhere separately...
    cheers

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi reminder,

    Thanks for getting back to me.
    I cannot see any conflict on the page as there are only 2 forms.

    Code:
    javascript: tmp='';for (i in document.forms) tmp+=(i)+'<br />';w=window.open('');w.document.write(tmp);
    length
    searchForm
    formWrap

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what you want to print into new window with this
    for (i in document.forms) tmp+=(i)+'<br />'; ?
    the (i) should be just i without brackets
    and i really dont know if the javascript support this vb for loop
    try to change the loop into
    var formList = document.getElementsByTagName("form"), i;
    for(i = 0; i < formList.length: i++) // loop
    cheers

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for getting back to me, I finally managed to find the source of the problem and it is extremely odd, as I have never seen this before.

    In a number of our pages, we had something similar to the following in the form and by having the name equal to submit causes the javascript submit to fail.

    HTML Code:
    <input type="submit" name="submit" value="View" />
    This was the case for both Firefox and IE, however renaming name="submit" to something else works correctly.

    PS. Reminder, that javascript for loop is perfectly valid have a look here for more details.


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
  •