質問編集履歴
1
タイトル設定、PG言語入力、コード入力をしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ホームページ上のフォームに数字を入れると、
|
1
|
+
###ホームページ上のフォームに数字を入れると、
|
2
2
|
計算結果と表示されるようにし、1つの図に折れ線グラフで
|
3
3
|
それぞれが比較して見られるものをJavaScriptで作りたいと
|
4
4
|
考えています。
|
@@ -27,4 +27,264 @@
|
|
27
27
|
今回質問をさせていただきました。
|
28
28
|
|
29
29
|
プログラミングに疎いもので、大変ワガママなお話で恐縮ですが、
|
30
|
-
ご教示いただけますと幸いです。
|
30
|
+
ご教示いただけますと幸いです。
|
31
|
+
|
32
|
+
```JavaScript
|
33
|
+
コード
|
34
|
+
```
|
35
|
+
<!doctype html>
|
36
|
+
<html>
|
37
|
+
<head>
|
38
|
+
<!-- Global site tag (gtag.js) - Google Analytics -->
|
39
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-138256867-1"></script>
|
40
|
+
<script>
|
41
|
+
window.dataLayer = window.dataLayer || [];
|
42
|
+
function gtag(){dataLayer.push(arguments);}
|
43
|
+
gtag('js', new Date());
|
44
|
+
|
45
|
+
gtag('config', 'UA-138256867-1');
|
46
|
+
</script>
|
47
|
+
|
48
|
+
<meta charset="utf-8">
|
49
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
50
|
+
<link rel="stylesheet" href="css/reset.css">
|
51
|
+
<link rel="stylesheet" href="css/style.css">
|
52
|
+
</style>
|
53
|
+
<script>
|
54
|
+
function sample() {
|
55
|
+
window.scrollTo(0,50);
|
56
|
+
}
|
57
|
+
</script>
|
58
|
+
</head>
|
59
|
+
<BODY >
|
60
|
+
<DIV class="container">
|
61
|
+
<DIV id="header">
|
62
|
+
<DIV id="header_bk">
|
63
|
+
<DIV id="header_top">
|
64
|
+
</DIV>
|
65
|
+
</DIV>
|
66
|
+
<section id="catMenu">
|
67
|
+
<ul class="flex">
|
68
|
+
<li class="btn"><a href="index.html">Infomation</a></li>
|
69
|
+
<li class="btn"><a href="simulation.html">Simulation</a></li>
|
70
|
+
<li class="btn"><a href="question.html">Question</a></li>
|
71
|
+
<li class="btn"></li>
|
72
|
+
</ul>
|
73
|
+
</section>
|
74
|
+
<section id="catBtnsSection">
|
75
|
+
<div class="flex between cate">
|
76
|
+
<div><a href="index.html"><img src="images/infomation.png" alt=""></a></div>
|
77
|
+
<div><a href="simulation.html"><img src="images/simulation.png" alt=""></a></div>
|
78
|
+
<div><a href="question.html"><img src="images/question.png" alt=""></a></div>
|
79
|
+
</div>
|
80
|
+
</section>
|
81
|
+
</DIV>
|
82
|
+
<div class="wrap">
|
83
|
+
<DIV class="contents">
|
84
|
+
<section class="conTabel">
|
85
|
+
<form>
|
86
|
+
<h2>Simulation</h2>
|
87
|
+
<p class="descr">※元金と期間を入力すると下の表に未来の予測金額をシミュレートします。</p>
|
88
|
+
<p><label for="textForm">元金 : </label>
|
89
|
+
<input type="text" id="textForm"><label for="textForm"> ドル </label></p>
|
90
|
+
<p><label for="textForm2">期間 : </label>
|
91
|
+
<input type="text" id="textForm2"><label for="textForm2"> 年後</label></p>
|
92
|
+
|
93
|
+
<div class="buttonWrap"><button id="button">シミュレートする</button></div>
|
94
|
+
</form>
|
95
|
+
<div class="tableWrap">
|
96
|
+
<table>
|
97
|
+
<tr>
|
98
|
+
<th>種目</th>
|
99
|
+
<th>銀行</th>
|
100
|
+
<th class="tablePoint">商品A</th>
|
101
|
+
<th>仮想通貨</th>
|
102
|
+
<th>FX</th>
|
103
|
+
<th>不動産</th>
|
104
|
+
</tr>
|
105
|
+
<tr>
|
106
|
+
<td align="right" nowrap>保証</td>
|
107
|
+
<td valign="top">○</td>
|
108
|
+
<td class="tablePoint" valign="top" >○</td>
|
109
|
+
<td valign="top" >×</td>
|
110
|
+
<td valign="top" >×</td>
|
111
|
+
<td valign="top" >△</td>
|
112
|
+
</tr>
|
113
|
+
<tr>
|
114
|
+
<td bgcolor="#99CC00" align="right" nowrap>利率</td>
|
115
|
+
<td valign="top">0.01%</td>
|
116
|
+
<td class="tablePoint" valign="top" >250%</td>
|
117
|
+
<td valign="top" >15% - 876%</td>
|
118
|
+
<td valign="top" >50%</td>
|
119
|
+
<td valign="top" >105%</td>
|
120
|
+
</tr>
|
121
|
+
<tr>
|
122
|
+
<td id="resultForm0" bgcolor="#99CC00" align="right" nowrap>年月</td>
|
123
|
+
<td id="resultForm1" valign="top">ドル</td>
|
124
|
+
<td class="tablePoint" id="resultForm2" valign="top" >ドル</td>
|
125
|
+
<td id="resultForm3" valign="top" >ドル</td>
|
126
|
+
<td id="resultForm4" valign="top" >ドル</td>
|
127
|
+
<td id="resultForm5" valign="top" >ドル</td>
|
128
|
+
</tr>
|
129
|
+
<tr>
|
130
|
+
<td bgcolor="#99CC00" align="right" nowrap>サービス</td>
|
131
|
+
<td valign="top">-</td>
|
132
|
+
<td valign="top" >-</td>
|
133
|
+
<td valign="top" >-</td>
|
134
|
+
<td valign="top" >-</td>
|
135
|
+
</tr>
|
136
|
+
<tr>
|
137
|
+
<td bgcolor="#99CC00" align="right" nowrap>詳細・特徴・将来性</td>
|
138
|
+
<td valign="top"><a href="https://www.jp-bank.japanpost.jp/kojin/chokin/tujo/kj_cho_tj_index.html" rel="noreferrer">郵貯HPへ</a></td>
|
139
|
+
<td valign="top" >-</td>
|
140
|
+
<td valign="top" >-</td>
|
141
|
+
<td valign="top" >-</td>
|
142
|
+
</tr>
|
143
|
+
</table>
|
144
|
+
</div>
|
145
|
+
</section>
|
146
|
+
</DIV>
|
147
|
+
</div>
|
148
|
+
<FOOTER id="footer_notfix_gray_login">
|
149
|
+
<div class="footerWrap"></div>
|
150
|
+
<DIV class="upper" onclick="sample()">^ </DIV>
|
151
|
+
<div class="fotterFont">
|
152
|
+
<ADDRESS class="footer_copy">
|
153
|
+
※掲載されている情報は、投資判断の参考として投資一般に関する情報提供を目的とするものであり、投資の最終決定はご自身の判断でなさるようにお願いいたします。
|
154
|
+
</ADDRESS>
|
155
|
+
<ADDRESS class="footer_copy">
|
156
|
+
</ADDRESS>
|
157
|
+
<div class="pcflex">
|
158
|
+
<!--<TABLE class="ftabele">
|
159
|
+
<TBODY>
|
160
|
+
<TR>
|
161
|
+
<TD><IMG class="footerlink_icon" src="images/arrow_small.png"></TD>
|
162
|
+
<TD><A class="footerlink_link" href="poricy.html">poricy</A></TD>
|
163
|
+
</TR>
|
164
|
+
</TBODY>
|
165
|
+
</TABLE>
|
166
|
+
<TABLE class="ftabele">
|
167
|
+
<TBODY>
|
168
|
+
<TR>
|
169
|
+
<TD><IMG class="footerlink_icon" src="images/arrow_small.png"></TD>
|
170
|
+
<TD><A class="footerlink_link" href="toc.html">Terms of Service</A></TD>
|
171
|
+
</TR>
|
172
|
+
</TBODY>
|
173
|
+
</TABLE>-->
|
174
|
+
</div>
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
</FOOTER>
|
178
|
+
</BODY>
|
179
|
+
|
180
|
+
|
181
|
+
<script>
|
182
|
+
|
183
|
+
// ボタンの要素を取得
|
184
|
+
var button = document.getElementById("button");
|
185
|
+
|
186
|
+
// ボタンをクリックした時の処理
|
187
|
+
button.addEventListener("click", function(e) {
|
188
|
+
|
189
|
+
e.preventDefault();
|
190
|
+
|
191
|
+
// 入力フォームの値を取得
|
192
|
+
var textForm = document.getElementById("textForm").value;
|
193
|
+
var textForm2 = document.getElementById("textForm2").value;
|
194
|
+
|
195
|
+
//全角数字を半角数字に変換(textForm)
|
196
|
+
var before = new Array("1","2","3","4","5","6","7","8","9","0");
|
197
|
+
var after=new Array("1","2","3","4","5","6","7","8","9","0");
|
198
|
+
var val = textForm;
|
199
|
+
|
200
|
+
var bef = before;
|
201
|
+
var aft = after;
|
202
|
+
|
203
|
+
for (i = 0; i < aft.length; i++) {
|
204
|
+
reg = new RegExp(bef[i], "g");
|
205
|
+
val = val.replace(reg, aft[i]);
|
206
|
+
}
|
207
|
+
textForm=Number(val);
|
208
|
+
|
209
|
+
//全角数字を半角数字に変換(textForm2)
|
210
|
+
var before = new Array("1","2","3","4","5","6","7","8","9","0");
|
211
|
+
var after=new Array("1","2","3","4","5","6","7","8","9","0");
|
212
|
+
var val = textForm2;
|
213
|
+
|
214
|
+
var bef = before;
|
215
|
+
var aft = after;
|
216
|
+
|
217
|
+
for (i = 0; i < aft.length; i++) {
|
218
|
+
reg = new RegExp(bef[i], "g");
|
219
|
+
val = val.replace(reg, aft[i]);
|
220
|
+
}
|
221
|
+
textForm2=Number(val);
|
222
|
+
|
223
|
+
|
224
|
+
// 取得した値を別の表に表示
|
225
|
+
document.getElementById("resultForm0").innerText = textForm2+"年後";
|
226
|
+
|
227
|
+
// 取得した値を別の表に表示
|
228
|
+
var result = textForm*(1.0001**textForm2);
|
229
|
+
// 数字を丸く
|
230
|
+
result = result*100;
|
231
|
+
result = Math.round(result);
|
232
|
+
result = result/100;
|
233
|
+
// 3桁ごとにカンマ
|
234
|
+
var num = new String( result );
|
235
|
+
while( num != ( num = num.replace( /(\d)((\d\d\d)+\b)/, '$1,$2' ) ) );
|
236
|
+
result = num;
|
237
|
+
document.getElementById("resultForm1").innerText = result+"ドル";
|
238
|
+
|
239
|
+
// 取得した値を別の表に表示
|
240
|
+
result = textForm*(2.5**textForm2);
|
241
|
+
result = result*100;
|
242
|
+
result = Math.round(result);
|
243
|
+
result = result/100;
|
244
|
+
num = new String( result );
|
245
|
+
while( num != ( num = num.replace( /(\d)((\d\d\d)+\b)/, '$1,$2' ) ) );
|
246
|
+
result = num;
|
247
|
+
document.getElementById("resultForm2").innerText = result+"ドル";
|
248
|
+
|
249
|
+
// 取得した値を別の表に表示
|
250
|
+
result = textForm*(0.015**textForm2);
|
251
|
+
result = result*100;
|
252
|
+
result = Math.round(result);
|
253
|
+
result = result/100;
|
254
|
+
num = new String( result );
|
255
|
+
while( num != ( num = num.replace( /(\d)((\d\d\d)+\b)/, '$1,$2' ) ) );
|
256
|
+
result = num;
|
257
|
+
var result2 = textForm*(8.76**textForm2);
|
258
|
+
result2 = result2*100;
|
259
|
+
result2 = Math.round(result2);
|
260
|
+
result2 = result2/100;
|
261
|
+
num = new String( result2 );
|
262
|
+
while( num != ( num = num.replace( /(\d)((\d\d\d)+\b)/, '$1,$2' ) ) );
|
263
|
+
result2 = num;
|
264
|
+
document.getElementById("resultForm3").innerText = result+"ドル - "+result2+"ドル";
|
265
|
+
|
266
|
+
// 取得した値を別の表に表示
|
267
|
+
result = textForm*(0.5**textForm2);
|
268
|
+
result = result*100;
|
269
|
+
result = Math.round(result);
|
270
|
+
result = result/100;
|
271
|
+
num = new String( result );
|
272
|
+
while( num != ( num = num.replace( /(\d)((\d\d\d)+\b)/, '$1,$2' ) ) );
|
273
|
+
result = num;
|
274
|
+
document.getElementById("resultForm4").innerText = result+"ドル";
|
275
|
+
|
276
|
+
// 取得した値を別の表に表示
|
277
|
+
result = textForm*(1.05**textForm2);
|
278
|
+
result = result*100;
|
279
|
+
result = Math.round(result);
|
280
|
+
result = result/100;
|
281
|
+
num = new String( result );
|
282
|
+
while( num != ( num = num.replace( /(\d)((\d\d\d)+\b)/, '$1,$2' ) ) );
|
283
|
+
result = num;
|
284
|
+
document.getElementById("resultForm5").innerText = result+"ドル";
|
285
|
+
|
286
|
+
|
287
|
+
});
|
288
|
+
|
289
|
+
</script>
|
290
|
+
</html>
|