How to start and end a program using two functions in the same onclick , please ?! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to start and end a program using two functions in the same onclick , please ?!

16th Nov 2020, 12:30 PM
Riselda Rada
Riselda Rada - avatar
6 Answers
0
You have named functions as f1 and f2 but using as func() is wrong.. Use f1() , f2() in onclick="f1()" for 1st radio buttons.. And ids should be unique in your total program so take different ids for <p>tags like <p id="msg1"></p> <p id="msg2"></p> For 2nd radio button take : onclick="f2()" And change in these id names like : document.getElementById("msg1").innerHTML="correct"; document.getElementById("msg2").innerHTML="correct"; And remove extra brace { in line number 42.. Edit : Riselda Rada You can share code link here like this : https://code.sololearn.com/WYeKxLp98s4c/?ref=app
16th Nov 2020, 2:39 PM
Jayakrishna 🇮🇳
+ 2
There are multiple way here are some you can use nested function (onClick="func()") //nested function function func() //1st function function secondFunc(){ //2nd function } secondFunc() } or you can do <button onclick="func(),secondFunc() ">click </button> function func() //1st function } function secondFunc(){ //2nd function }
16th Nov 2020, 1:37 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 1
Okay i am trying , thank you🤗
16th Nov 2020, 2:11 PM
Riselda Rada
Riselda Rada - avatar
+ 1
Could you please look in my profile , it's called Game3 . I don't know what is going wrong with my code 🙁
16th Nov 2020, 2:18 PM
Riselda Rada
Riselda Rada - avatar
+ 1
Thank you very much !! You helped me a lot😊😊
16th Nov 2020, 4:46 PM
Riselda Rada
Riselda Rada - avatar
0
Try this : onclick =" function1(), function2()"
16th Nov 2020, 1:38 PM
Jayakrishna 🇮🇳