Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Unhappy Quick onClick Question

    Hi guys,

    It's probably just bad syntax, but what is wrong with this? I've chopped it and tried it using document.forms.formName and document.formName... Need a quick hand...:

    Code:
    <A HREF="http://ww.address.com/index.php?page=2" onclick="document.MainForm.submit();">Next Page</A>
    Doesn't submit the data... I've copied the syntax verbatim from tutorials... Nothing seems to work...

    Thanks,
    Jesse.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Why do you need a link to submit the form instead of usual input type="submit"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    if you have an input type=file in there, then it won't work.
    otherwise try document.form.submit(); or document.forms[0].submit(); or give your form an id instead of a name and use document.getElementById("my_forms_id").submit();
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • Users who have thanked mjlorbet for this post:

    Jester1981 (04-29-2008)

  • #4
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks to you both, particularly mjlorbet - I will try that to see if it makes a difference but I have just reailsed that if it does fix it, it won't resolve the bigger problem. I am taking the wrong path...

    Cheers,
    Jesse.

  • #5
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    I think you have an issue that the link is executing. You need to add return false to the end of the onclick. With the way you have it coded, it is a race to see if the form or if the link executes first.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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