22nd Oct 2023, 7:31 PM
Abdel Qb
Abdel Qb - avatar
5 Respuestas
+ 8
What you want to achieve. I think you need to learn again about function, function parameter and how to get input value in JavaScript. also learn how to make input box in html
22nd Oct 2023, 8:02 PM
A͢J
A͢J - avatar
+ 6
<!--for html 1- remore the semicolins ; from input and close the quotes "number" 2- remove the dot between button and onlcick and leave a space --> /* for javascript 1- no need for the parameters x, y you can leave it with empty parentheses somme() 2- all the lines inside the function that come after return will not run, so you should remove it. 3- you do not need to call the function inside itself. 4- you should put all the code inside the function so it execute all when you click the button 5- create variable z which adds x and y, you will need to convert them to integers with parseInt function 6- also close the ) before .value for sum */
22nd Oct 2023, 8:14 PM
Mafdi
Mafdi - avatar
+ 3
It looks like this is a homework assignment that you have to solve yourself by fixing all the bugs written by the teacher.
22nd Oct 2023, 9:36 PM
Solo
Solo - avatar
0
// Created by Abdel Qb function somme() { var x = parseFloat(document.getElementById("nbr1").value); var y = parseFloat(document.getElementById("nbr2").value); var z = x + y; document.getElementById("sum").innerHTML = z; } <!-- Created by Abdel Qb --> <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <input type="number" id="nbr1"> <input type="number" id="nbr2"> </br> <button Onclick="somme ();"> la somme est :</button> <br><br>Result is <div id="sum"> </div> </body> </html>
24th Oct 2023, 11:22 AM
Satyam Verma
Satyam Verma - avatar
0
Thanks Satyam🙏🙏
24th Oct 2023, 7:47 PM
Abdel Qb
Abdel Qb - avatar