015:小奇麗にしましょう。(最終回)

chshcky : 2018/01/14(日) - 02:16

1."Section-014.html"をコピーして編集

  • "Section-014.html"をコピーして"Section-015.html"を作成(?→008,014)
  • After
<script>
    function showAnswerTop() {
        showSumAndDif("left1", "right1");
    }

    function showAnswerBottom() {
        showSumAndDif("left2", "right2");
    }

    function showSumAndDif(leftId, rightId) {
        var leftValue = Number(document.getElementById(leftId).value);
        var rightValue = Number(document.getElementById(rightId).value);
        var sum = leftValue + rightValue;
        alert(leftValue + "+" + rightValue + "=" + sum);
        var dif = leftValue - rightValue;
        alert(leftValue + "-" + rightValue + "=" + dif);
    }
</script>

<input id="left1" type="text" value="1"> +,- <input id="right1" type="text" value="2">
<input type="button" value="?" onclick="showAnswerTop();">
<br>
<input id="left2" type="text" value="3"> +,- <input id="right2" type="text" value="4">
<input type="button" value="?" onclick="showAnswerBottom();">

Section-014.html → Section-015.html RENAMED
1
1
<script>
2
2
function showAnswerTop() {
3
 
- var leftValue = Number(document.getElementById("left1").value);
 
3
+ showSumAndDif("left1", "right1");
4
 
- var rightValue = Number(document.getElementById("right1").value);
5
 
- var sum = leftValue + rightValue;
6
 
- alert(leftValue + "+" + rightValue + "=" + sum);
7
 
- var dif = leftValue - rightValue;
8
 
- alert(leftValue + "-" + rightValue + "=" + dif);
9
4
}
10
5
 
11
6
function showAnswerBottom() {
12
 
- var leftValue = Number(document.getElementById("left2").value);
13
 
- var rightValue = Number(document.getElementById("right2").value);
 
7
+ showSumAndDif("left2", "right2");
 
8
+ }
 
9
+
 
10
+ function showSumAndDif(leftId, rightId) {
 
11
+ var leftValue = Number(document.getElementById(leftId).value);
 
12
+ var rightValue = Number(document.getElementById(rightId).value);
14
13
var sum = leftValue + rightValue;
15
14
alert(leftValue + "+" + rightValue + "=" + sum);
16
15
var dif = leftValue - rightValue;
  • 保存する[Ctrl+S]

section-015_edit.gif

2.Edgeで開いて答を見る

  • "Section-015.html"を"Microsoft Edge"で開く(?→004)
  • 上の"?"をクリック
  • 下の"?"をクリック

section-015_open.gif

     

Comments

Non Prescription Online Pharmaceuticals Prescriptiondrugswithoutprescription cialis Unicure Remedies Pvt Ltd Cialis Ou Acheter Direct isotretinoin website no doctors consult pharmacy

Comment