Hello, this is my first post on this site and I would like a help, I need to create a calculator so that the user can put the name so that when the alert displays the result, the name appears, for example: '' Hello , Mark, the result of the sum is: X ''
The code is below, I need only the modification to create the box to write the name and the modification in the alert.
Thank you.
<html>
<header>
<title>Calculadora</title>
<script type="text/javascript">
function somarValores(){
var n1 = document.getElementById("s1").value;
var n2 = document.getElementById("s2").value;
var n3 = parseInt(n1) + parseInt(n2);
alert(n3);
}
function multiplicarValores(){
var n1 = document.getElementById("s1").value;
var n2 = document.getElementById("s2").value;
var n3 = parseInt(n1) * parseInt(n2);
alert(n3);
}
function dividirValores(){
var n1 = document.getElementById("s1").value;
var n2 = document.getElementById("s2").value;
var n3 = parseInt(n1) / parseInt(n2);
alert(n3);
}
function subtrairValores(){
var n1 = document.getElementById("s1").value;
var n2 = document.getElementById("s2").value;
var n3 = parseInt(n1) - parseInt(n2);
alert(n3);
}
</script>
</header>
<body>
Hello world
<legend>somas</legend>
<label>Valor 1:</label>
<input id="s1" type="text"/>
<label>Valor 2:</label>
<input id="s2" type="text"/>
<button id="somar" onclick="somarValores()">Somar</button>
<button id="multiplicar" onclick="multiplicarValores()">multiplicar</button>
<button id="dividir" onclick="dividirValores()">dividir</button>
<button id="subtrair" onclick="subtrairValores()">subtrair</button>
</body>
</body>
</html>