質問するログイン新規登録

質問編集履歴

3

ソースコードの追加

2018/11/14 04:20

投稿

monolith123
monolith123

スコア20

title CHANGED
File without changes
body CHANGED
@@ -13,6 +13,15 @@
13
13
  ### 該当のソースコード
14
14
 
15
15
  ```javascript
16
+ /*
17
+ 今日の日付データを変数todayに格納
18
+ */
19
+ var optionLoop, this_day, this_month, this_year, today;
20
+ today = new Date();
21
+ this_year = today.getFullYear();
22
+ this_month = today.getMonth() + 1;
23
+ this_day = today.getDate();
24
+
16
25
  optionLoop = function (start, end, id, this_day) {
17
26
  var i, opt;
18
27
 
@@ -37,7 +46,7 @@
37
46
  var minute = [':00', ':30'];
38
47
  var count = 0;
39
48
  for (var hour = 0; hour <= 24;) {
40
- if (i === this_day) {
49
+ if (i === this_time) {
41
50
  opt += "<option value='" + hour + "' selected>" + hour + "</option>";
42
51
  } else {
43
52
  opt += "<option value='" + hour + "'>" + hour + "</option>";
@@ -53,6 +62,26 @@
53
62
  ```
54
63
 
55
64
  ```HTML
65
+ <!-- 日付表示 -->
66
+ <script type="text/javascript">
67
+ /*
68
+ 関数設定(スタート数字、終了数字、表示id名、デフォルト数字)
69
+ */
70
+ $(function() {
71
+ optionLoop(this_year - 5, this_year + 5, 'id_year', this_year);
72
+ optionLoop(1, 12, 'id_month', this_month);
73
+ optionLoop(1, 31, 'id_day', this_day);
74
+ })
75
+
76
+ $(function() {
77
+ optionLoop(this_year - 5, this_year + 5, 'bar_year', this_year);
78
+ optionLoop(1, 12, 'bar_month', this_month);
79
+ optionLoop(1, 31, 'bar_day', this_day);
80
+ })
81
+ </script>
82
+ </head>
83
+
84
+
56
85
  <tr>
57
86
  <td>開始時間</td>
58
87
  <td>

2

文書の追加

2018/11/14 04:20

投稿

monolith123
monolith123

スコア20

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,7 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
3
  プルダウンメニューの初期表示を特定の時間にしたいのですがうまくいきません
4
+ アドバイスお願いします。
4
5
 
5
6
 
6
7
  ### 発生している問題・エラーメッセージ

1

文書の変更

2018/11/14 02:58

投稿

monolith123
monolith123

スコア20

title CHANGED
File without changes
body CHANGED
@@ -6,7 +6,7 @@
6
6
  ### 発生している問題・エラーメッセージ
7
7
 
8
8
  ```
9
- エラーッセ
9
+ 0時から24時のプルダウンニュで初期表示を9時に設定できない
10
10
  ```
11
11
 
12
12
  ### 該当のソースコード
@@ -81,12 +81,4 @@
81
81
  </select>
82
82
  </td>
83
83
  </tr>
84
- ```
84
+ ```
85
-
86
- ### 試したこと
87
-
88
- ここに問題に対して試したことを記載してください。
89
-
90
- ### 補足情報(FW/ツールのバージョンなど)
91
-
92
- ここにより詳細な情報を記載してください。