Created
April 24, 2013 03:06
-
-
Save chikoski/5449290 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input{ | |
display: inline; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>計算機</title> | |
</head> | |
<body> | |
<form> | |
<input type="text" size="5" id="a"> + | |
<input type="text" size="5" id="b"> = | |
<input type="text" size="5" id="c"> | |
</form> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var calc = function(e){ | |
var input_a = document.getElementById("a"); | |
var input_b = document.getElementById("b"); | |
var input_c = document.getElementById("c"); | |
var a = Number(input_a.value); | |
var b = Number(input_b.value); | |
var c = a + b; | |
input_c.value = c; | |
}; | |
var input_a = document.getElementById("a"); | |
var input_b = document.getElementById("b"); | |
input_a.onchange = calc; | |
input_b.onchange = calc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment