-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completed #10
base: master
Are you sure you want to change the base?
Completed #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,94 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Worlds Best Calculator</title> | ||
|
||
<!-- CSS only --> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> | ||
|
||
<style> | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
</style> | ||
.button { | ||
width: 50; | ||
height: 50; | ||
font-size: 30; | ||
margin: 5; | ||
cursor: pointer; | ||
} | ||
|
||
<script> | ||
var calculator = { | ||
addNumbers: function () { | ||
// hint: these are strings | ||
var numberOne = document.forms.inputs.numberOne.value; | ||
var numberTwo = document.forms.inputs.numberTwo.value; | ||
document.forms.inputs.result.value = numberOne + numberTwo; | ||
}, | ||
subtractNumbers: function () { | ||
|
||
} | ||
.textview { | ||
width: 240; | ||
margin: 3; | ||
font-size: 40; | ||
padding: 3; | ||
} | ||
</style> | ||
|
||
|
||
</script> | ||
|
||
</head> | ||
|
||
<body> | ||
<div>Header</div> | ||
<div> | ||
<!-- | ||
- allow two numbers to be entered | ||
- show buttons for add and subtract | ||
- show the result | ||
--> | ||
<form name="inputs"> | ||
<div> | ||
Number 1: | ||
<input type="number" name="numberOne" class="form-control" placeholder="First number" aria-label="Number1" > | ||
</div> | ||
<div> | ||
Number 2: | ||
<input type="number" class="form-control" name="numberTwo"> | ||
</div> | ||
<div> | ||
<button type="button" class="btn btn-primary" onclick="calculator.addNumbers()" >Add</button> | ||
<button type="button" class="btn btn-primary">Substract</button> | ||
</div> | ||
<div> | ||
<input name="result" value="0" class="form-control" disabled /> | ||
</div> | ||
<div class="main"> | ||
<form name="form"> | ||
<input class="textview" name="textview"> | ||
</form> | ||
<table> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These number buttons are not needed for this assignment. We want to have the input fields for users to type in the number values as we started in the template in class and the repo we pulled from originally. |
||
<tr> | ||
<td><input class="button" type="button" value="1" onclick="insert(1)"></td> | ||
<td><input class="button" type="button" value="2" onclick="insert(2)"></td> | ||
<td><input class="button" type="button" value="3" onclick="insert(3)"></td> | ||
<td><input class="button" type="button" value="+" onclick="insert('+')"></td> | ||
</tr> | ||
<tr> | ||
<td><input class="button" type="button" value="4" onclick="insert(4)"></td> | ||
<td><input class="button" type="button" value="5" onclick="insert(5)"></td> | ||
<td><input class="button" type="button" value="6" onclick="insert(6)"></td> | ||
<td><input class="button" type="button" value="-" onclick="insert('-')"></td> | ||
</tr> | ||
<tr> | ||
<td><input class="button" type="button" value="7" onclick="insert(7)"></td> | ||
<td><input class="button" type="button" value="8" onclick="insert(8)"></td> | ||
<td><input class="button" type="button" value="9" onclick="insert(9)"></td> | ||
<td><input class="button" type="button" value="*" onclick="insert('*')"></td> | ||
</tr> | ||
<tr> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this assignment, these are the only buttons needed for Add, Subtract, Multiply, Divide. |
||
<td><input class="button" type="button" value="0" onclick="insert(0)"></td> | ||
<td><input class="button" type="button" value="." onclick="insert('.')"></td> | ||
<td><input class="button" type="button" value="=" onclick="equal()"></td> | ||
<td><input class="button" type="button" value="/" onclick="insert('/')"></td> | ||
|
||
</tr> | ||
<tr> | ||
</tr> | ||
|
||
|
||
|
||
|
||
</table> | ||
|
||
|
||
</div> | ||
<div>Footer</div> | ||
|
||
<body bgcolor="blue"></body> | ||
|
||
<script> | ||
function insert(num) { | ||
document.form.textview.value = document.form.textview.value + num | ||
} | ||
|
||
function equal() { | ||
var exp = document.form.textview.value; | ||
if (exp) { | ||
document.form.textview.value = eval(exp) | ||
} | ||
} | ||
|
||
function clean() { | ||
document.form.textview.value = ""; | ||
} | ||
</script> | ||
|
||
|
||
|
||
|
||
</body> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of the
*
selector here. Other css looks good but is missing thepx
with the numbers.For example see the use of px with numbers in this snippet.
See this page for more help https://www.w3schools.com/cssref/css_units.asp