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 3 of 3
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts

    OnClick = Disable Button, Text in Form = Enable Button

    I have a message system that I want to prevent double posting. So when a user sends a message i would like to disable the button. But its done using AJAX and will load without much time. But enough to cause double clicking. So now the button needs to be enabled once Text is put in the Form Field.

    Make sense??
    thanks

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,080
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Is this what you are wanting?

    Code:
    Message <input type = "text" id = "txt1" onfocus = "en()"><br>
    <input type = "button" id = "but1" value = "Send Message" disabled = true onclick = "dis()">
    
    <script type = "text/javascript">
    function en() {
    document.getElementById("but1").disabled = false;
    }
    function dis() {
    document.getElementById("txt1").value = "";
    document.getElementById("but1").disabled = true;
    window.setTimeout("en()",5000);   // disable for 5 seconds
    }
    
    </script>
    Lottery: A tax on people who are bad at math.
    Last edited by Philip M; 05-19-2009 at 08:02 PM.

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts
    This will work Super-Duper!!

    Thanks Alot!


  •  

    Tags for this Thread

    Posting Permissions

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