+ 1
Help to resolve this problem
5 ответов
+ 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
+ 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
*/
+ 3
It looks like this is a homework assignment that you have to solve yourself by fixing all the bugs written by the teacher.
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>
0
Thanks Satyam🙏🙏