-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.js
49 lines (38 loc) · 1.72 KB
/
javascript.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
49
// open document function to start it all off
$(function() {
// function to run every time a click happens - redirect to the appropriate DemDigits function referenced in line 7
var buttonCheck = false;
$("#submit").click(function(){
var firstInteger = $('#firstInteger').val();
var secondInteger = $('#secondInteger').val();
// var buttonCheck = $('#additionButton').val();
// console.log(buttonCheck);
if($("#additionButton").prop("checked"))
{
var totalAdd = (eval(firstInteger) + eval(secondInteger));
var totalSubtract = (eval(firstInteger) - eval(secondInteger));
var totalMultiply = (eval(firstInteger) * eval(secondInteger));
var totalDivide = (eval(firstInteger) / eval(secondInteger));
$('#historyOutput').prepend('<div>' + firstInteger + '+' + secondInteger + '=' + totalAdd + '</div>');
}
if($("#subtractionButton").prop("checked"))
{
var totalSubtract = (eval(firstInteger) - eval(secondInteger));
$('#historyOutput').prepend('<div>' + firstInteger + '-' + secondInteger + '=' + totalSubtract + '</div>');
}
if($("#multiplyButton").prop("checked"))
{
var totalMultiply = (eval(firstInteger) * eval(secondInteger));
$('#historyOutput').prepend('<div>' + firstInteger + '*' + secondInteger + '=' + totalMultiply + '</div>');
}
if($("#divideButton").prop("checked"))
{
var totalDivide = (eval(firstInteger) / eval(secondInteger));
$('#historyOutput').prepend('<div>' + firstInteger + '/' + secondInteger + '=' + totalDivide + '</div>');
}
if($("#divideButton" || "#multiplyButton" || "#additionBdutton" || "subtractionButton").prop("checked", false))
{
alert("null!");
};
});
});