animation and event handling | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

animation and event handling

i have a form which when submitted, an animation starts of some duration(say 10s).... after the animation ends, i want an alert message to be displayed... how can i do that? (i cannot use setTimeout because I'll not know how much time will the user take to submit the form....)

23rd Jan 2019, 4:42 PM
Ravindra Desai
Ravindra Desai - avatar
7 Answers
+ 3
You can use setTimeout. After exactly ten seconds after the button is pressed, you will get an alert. https://code.sololearn.com/WEr7TbRsGmcZ/?ref=app
23rd Jan 2019, 5:02 PM
Jax
Jax - avatar
+ 2
thanks Jax and 🌴Vincent Berger🌴 for your help... that really helped a lot 👍👍
24th Jan 2019, 2:54 AM
Ravindra Desai
Ravindra Desai - avatar
+ 1
Hi Ravindra Desai, Just use an if .. else stament that make the decision against the required input. 😊 Or, You can use an event listener to detect change or focus on the input tag. F.E. the client inserted the data to the input and when the client loses focus or changing focus to another HTML element then you can execute a code block based on that action. Have a look at this snippet👍😊 https://code.sololearn.com/WEGb3Ng2x9ki/?ref=app
23rd Jan 2019, 11:16 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
+ 1
Jax and 🌴Vincent Berger🌴 ...another help required 😅... i want an audio to play using javascript.. fr ex.. https://www.zedge.net/ringtone/6bf8b324-a3c7-34d8-ab6b-e915a6894308?utm_source=zedgeWeb&utm_medium=uploaderProfile&utm_campaign=sharing that link has an audio file.. how can i play that audio file as soon as a page loads(or any other event occurs using only javascript ) ??
24th Jan 2019, 4:46 AM
Ravindra Desai
Ravindra Desai - avatar
+ 1
Ravindra Desai, Download the file and upload it to your dropbox: https://www.sololearn.com/discuss/1054246/?ref=app Declare a new js audio object and give the source method your link. //_ var audio = new Audio(); audio.src("your_link"); audio.play; when playing audio via JS, you need a users gesture for initialization. https://www.w3schools.com/jsref/dom_obj_audio.asp
24th Jan 2019, 8:48 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
25th Jan 2019, 2:33 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
0
🌴Vincent Berger🌴 thanks.. it worked!! is there a way to play that audio twice continuously?
25th Jan 2019, 9:35 AM
Ravindra Desai
Ravindra Desai - avatar