SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: onclick event

  1. #1
    SitePoint Zealot
    Join Date
    Feb 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onclick event

    Hello,

    I have very intense php script that takes from 5 - 30 seconds to execute, depending on user request.

    So I want to prevent people from clicking "search" twice, so I decided to glue it by disabling button on click.

    Here is my code:
    PHP Code:
    <script type="text/javascript">
                function 
    disableButton(name)
                {
                
    document.getElementById(name).disabled=true;    
                
    document.getElementById(name).value="Working...";            
                return 
    true;
                }
                
    </script> 
    And yet my form submit:
    PHP Code:
    <input type="submit" value="Search" id="search1" onclick="disableButton('search1');"></input></form
    But, for some reason it won't proceed. JS executes fine, but form won't go on. What is wrong?

  2. #2
    SitePoint Zealot
    Join Date
    Feb 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, found the solution. Instead I tried onsubmit in <form > and it works:
    <form action="search.php?action=subscribers" method="post" onsubmit="disableButton('search1');">


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
  •