-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
48 lines (43 loc) · 1.07 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//To change text
function changeText(x){
var demo = document.getElementById("demo");
if(x.value == "addition"){
demo.innerHTML = "Addition";
}
if(x.value == "subtraction"){
demo.innerHTML = "Subtraction";
}
if(x.value == "multiplication"){
demo.innerHTML = "Multiplication";
}
if(x.value == "division"){
demo.innerHTML = "Division";
}
}
function calcFun(){
var selValue = document.forms["myform"]["sel"].value;
var field01 = document.forms["myform"]["field01"].value;
var field02 = document.forms["myform"]["field02"].value;
//convert string to integer with the parseInt()
var field01 = parseInt(field01);
var field02 = parseInt(field02);
switch(selValue){
case "addition":
document.getElementById("output").innerHTML = field01 + field02;
break;
case "subtraction":
document.getElementById("output").innerHTML = field01 - field02;
break;
case "multiplication":
document.getElementById("output").innerHTML = field01 * field02;
break;
case "division":
document.getElementById("output").innerHTML = field01 / field02;
break;
default:
//Blank
break;
}
return false;
}
//Built by Ashraf Otagun