-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.html
More file actions
162 lines (143 loc) · 6.11 KB
/
input.html
File metadata and controls
162 lines (143 loc) · 6.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>アクティビティ入力</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
// 現在日付を取得
var jnow = jQuery.now();
var nowdate = new Date(jnow);
var yyyymmdd = nowdate.getFullYear()
+ "" + ("0" + (nowdate.getMonth()+1)).slice(-2)
+ "" + ("0" + nowdate.getDate()).slice(-2);
// 現在日付を設定
var $aform = $('#actvform');
$aform.find("[name=date]").val(yyyymmdd);
// 編集不可の設定
$aform.find("[name=date]").attr("readonly",true);
// ページ読み込み時にユーザーID取得
var userId = localStorage.getItem("userId");
//var userId = "devdebu@devdebu.com";
$aform.find("[name=userId]").val(userId);
// サンプル値をランダムでセット
//$aform.find("[name=weight]").val(jnow%10+50);
//$aform.find("[name=fat]").val(jnow%5+19);
//$aform.find("[name=step]").val(jnow%30000);
//});
//jQuery(function($){
$(".btn_ajax").on("click", function(e) {
var button = $(this);
alert("入力内容を登録します");
// 操作対象のフォーム要素を取得
var $form = $("#actvform");
// 送信
$.ajax({
// 送信先URL
url:'https://deboo.mybluemix.net/v1/activity',
type: 'POST',
data: $form.serialize(),
timeout: 10000, // milliSecond
success: function(result, textStatus, xhr) {
// 入力値を初期化
$form[0].reset();
// 現在日付を取得
var jnow = jQuery.now();
var nowdate = new Date(jnow);
var yyyymmdd = nowdate.getFullYear()
+ "" + ("0" + (nowdate.getMonth()+1)).slice(-2)
+ "" + ("0" + nowdate.getDate()).slice(-2);
// 現在日付を設定
var $aform = $('#actvform');
$aform.find("[name=date]").val(yyyymmdd);
// 編集不可の設定
$aform.find("[name=date]").attr("readonly",true);
$("#errorMsg").html("");
$("#errorMsg").append(" <div class='alert alert-danger' id='myAlert'></div>");
$("#myAlert").append("登録しました。");
},
error: function(xhr, textStatus, error) {
$("#errorMsg").html("");
$("#errorMsg").append(" <div class='alert alert-danger' id='myAlert'></div>");
$("#myAlert").append("登録に失敗しました。");
}
});
});
});
</script>
<!-- css from myroom -->
<STYLE type="text/css">
BODY{color : white ;background-color : #272B30}
table{color : black;}
.debu-label{display: inline-block;width : 6em;text-align:right;}
.debu-txt{display: inline-block;width : 20em; margin-left:0.5em ;color : black;}
.debuBox{width:12em; background-color:lightskyblue; border:2px white double; margin-top:1em; margin-right:1em; margin-bottom:1em; margin-left:auto}
.debuVal{width:8em; display: inline-block;text-align: right;margin-left:0.5em;}
</STYLE>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbarEexample7">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="myroom.html">DevDebu</a>
</div>
<div class="collapse navbar-collapse" id="navbarEexample7">
<ul class="nav navbar-nav">
<li><a href="user.html">基本情報修正</a></li>
<li><a href="myroom.html">マイルームに戻る</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row-fluid">
<div class="col-xs-12 col-md-6 panel-primary">
<div class="panel-heading">
<div class="panel-title">アクティビティ</div>
</div>
<div class="panel-body panel">
<form method="POST" id="actvform" name="actvform">
<div class="login-block">
<div class="input-group margin-bottom-20">
<span class="input-group-addon rounded-left glyphicon glyphicon-calendar"></span>
<input type="text" class="form-control rounded-right" id="date" name="date">
</div>
<div class="input-group margin-bottom-20">
<span class="input-group-addon rounded-left glyphicon glyphicon-scale"></span>
<input type="number" class="form-control rounded-right" id="weight" placeholder="体重(kg)を入力してください。" name="weight">
</div>
<div class="input-group margin-bottom-20">
<span class="input-group-addon rounded-left glyphicon glyphicon-dashboard"></span>
<input type="number" class="form-control rounded-right" id="fat" placeholder="体脂肪率(%)を入力してください。" name="fat">
</div>
<div class="input-group margin-bottom-20">
<span class="input-group-addon rounded-left glyphicon glyphicon-fire"></span>
<input type="number" class="form-control rounded-right" id="step" placeholder="歩数を入力してください。" name="step">
</div>
<input type="hidden" name="userId" id="userId">
<div class="row margin-bottom-70">
<div class="col-md-12">
<button type="button" class ="btn btn-danger btn-block btn_ajax" action="actvform">INPUT</button>
</div>
</div>
</div>
</form>
<div id = "errorMsg"></div>
</div>
</div>
</div>
</div>
</body>
</html>