www.webdeveloper.com
Results 1 to 2 of 2

Thread: disable/enable form elements

  1. #1
    Join Date
    Feb 2009
    Posts
    21

    disable/enable form elements

    Sorry, problem fixed. The obvious solution was to reactivate the form inside the animation function.


    I have a form containing buttons that activate javascript functions. I want to prevent the user to activate a function before the previous one has been completed. Each function activates a timed animation.
    I have tried:

    Code:
    function animation1(){
     
        disableForm();
        doAnimation1():
        enableForm();
     
    }
    
    function disableForm(){
        var theForm;
        var length;
        var i;
        //ottieni la form
        theForm = document.getElementById("myform");
        for(i = 0; i < theForm.length; ++i)
            theForm.elements[i].disabled = true;
        
        
    }
    
    function enableForm(){
        var theForm;
        var length;
        var i;
        //ottieni la form
        theForm = document.getElementById("myform");
        for(i = 0; i < theForm.length; ++i)
            theForm.elements[i].disabled = false;
        
        
    }
    Problem is that enableForm is called before the animation has finished. I could put enableForm inside a setTimeout, but I don't know in advance how much time the animation takes because it depends by some user input.
    Last edited by cleanzero; 03-26-2009 at 08:26 AM. Reason: DELETED.

  2. #2
    Join Date
    Nov 2002
    Posts
    4,473
    You would have to place the enableForm() inside doAnimation1() after the animation is finished.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles