SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    on click: submit button disabled

    hello
    I am not a javascript techie,but would like to know...

    how do i get to disable the submit button on click ?

    thanks
    Afrika

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,449
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Put this javascript in the <head> of your document:

    Code:
    onsubmit = disableForm;
    
    function disableForm(){
        onsubmit = false;
    }

  3. #3
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot stymiee

    this is what i am doing, but its not working

    <input name="submit" type="submit" onsubmit = disableForm;function disableForm(){onsubmit = false;} value="send message" style="color: #000080; border: 1px solid #336699; background-color: #FFFFFF; font-family:Verdana; font-weight:bold">

  4. #4
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Try using the onclick event instead:

    HTML Code:
    <input name="submit" type="submit" onclick="this.disabled=true" value="send message" style="color: #000080; border: 1px solid #336699; background-color: #FFFFFF; font-family:Verdana; font-weight:bold">
    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  5. #5
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It worked
    thanks Erik

    Have a nice day
    Afrika

  6. #6
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WAIT A MINUTE, WAIT A MINUTE

    Your code just disables the form but does not submit the form

    I am trying to debug it, PLEASE WHAT IS WRONG

  7. #7
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or changing type ...

    HTML Code:
    Code:
    <input name="submit" type="submit" onclick="this.type='button' value="send message" style="color: #000080; border: 1px solid #336699; background-color: #FFFFFF; font-family:Verdana; font-weight:bold">

  8. #8
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <input name="submit" type="submit" onclick="this.type='button';this.form.submit();" value="send message" style="color: #000080; border: 1px solid #336699; background-color: #FFFFFF; font-family:Verdana; font-weight:bold">

  9. #9
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks SpaceFrog

    still gives errors

    error message:

    Could not get the type of property; this command is not supported

    I still need assistance

    Afrika

  10. #10
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <input name="submit" type="submit" onclick="this.type='button';document.forms[0].submit();" value="send message" style="color: #000080; border: 1px solid #336699; background-color: #FFFFFF; font-family:Verdana; font-weight:bold">

  11. #11
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    apparently you can read type
    HTML Code:
    alert(document.testform.butsubm.type)
    but not modify it...
    I would try to launch a function in the onsubmit event of the form


    disbaling the button seems to be the solution, but in the onsubmit event of your form:

    HTML Code:
    document.testform.butsubm.disabled=true;return true;"

  12. #12
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,449
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    The code I provided should work without any modification to your form. Just put it in the head of your page and you should be fine. No need to make it any more complex then it already is.

  13. #13
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot, i finally got it to work as i wanted

    Afrika


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
  •