/    Sign up×
Community /Pin to ProfileBookmark

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;

}

[/CODE]

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.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisApr 01.2009 — You would have to place the enableForm() inside doAnimation1() after the animation is finished.
×

Success!

Help @cleanzero spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...