質問編集履歴

3

書式の改善

2017/05/30 18:10

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -94,9 +94,11 @@
94
94
 
95
95
  ____________________________________________________________________
96
96
 
97
- $(function(){
97
+ $(document).ready(function() {
98
98
 
99
- $("#completion").click(function(){
99
+ $(document).on('click',"#completion",function(){
100
+
101
+ alert("kurikku")
100
102
 
101
103
  var user = JSON.parse(sessionStorage.getItem("user"));
102
104
 
@@ -104,32 +106,26 @@
104
106
 
105
107
  var subtotal = sessionStorage.getItem("subtotal");
106
108
 
107
- var users = {
109
+ var users = {
108
110
 
109
- "userid": user.user_id,
111
+ "userid": user.user_id,
110
112
 
111
- "subtotal": subtotal,
113
+ "subtotal": subtotal,
112
114
 
113
- "products":
115
+ "products":
114
116
 
115
- [
117
+ [
116
118
 
117
- {
119
+ {
118
120
 
119
- "productid": list.productid,
121
+ "productid": list[i].productid,
120
122
 
121
- "quantity": list.quantity
123
+ "quantity": list[i].quantity
122
124
 
123
- }
125
+ }
124
126
 
125
- ]
127
+ ]
126
128
 
127
- }
129
+ }
128
130
 
129
131
  ```
130
-
131
- }
132
-
133
- ;sessionStorage.setItem("users", JSON.stringify(users));
134
-
135
- ```

2

文法修正、JSON書式改善、エラー一つ改善

2017/05/30 18:10

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,12 +1,22 @@
1
- こんばんは、セッションストレージからデータを取得してJSON形式にしたいのですが、"productid"と
1
+ こんばんは、セッションストレージからデータを取得してJSON形式にしたいのですが、配列になっている"productid"と"quantity"に複数の値をいれる方法がわかりません。
2
2
 
3
- "quantity"に複数の値をいれる方法がわかりません。
3
+ 形としては [{
4
4
 
5
- また"subtotal": subtotalとしているのですが使用できないstringだと怒られます。
5
+ "productid": list.productid,
6
6
 
7
- var subtotal = sessionStorage.getItem("subtotal");
7
+ "quantity": list.quantity
8
8
 
9
+ },
10
+
11
+ {
12
+
13
+ "productid": list.productid,
14
+
15
+ "quantity": list.quantity
16
+
17
+ }]
18
+
9
- で扱えるようになってるとはおもうのです。。
19
+ 配列の中に複数の値を持てるようしたいです。
10
20
 
11
21
  お力添えいただけるとうれしいです。
12
22
 
@@ -94,23 +104,27 @@
94
104
 
95
105
  var subtotal = sessionStorage.getItem("subtotal");
96
106
 
97
- var users = {
107
+ var users = {
98
108
 
99
- "userid": user.user_id,
109
+ "userid": user.user_id,
100
110
 
101
- [ {
111
+ "subtotal": subtotal,
102
112
 
103
- "productid" : list.productid,
113
+ "products":
104
114
 
105
- "quantity" : list.quantity
115
+ [
106
116
 
107
- }
117
+ {
108
118
 
109
- ]
119
+ "productid": list.productid,
110
120
 
111
- ```ここに言語を入力
121
+ "quantity": list.quantity
112
122
 
113
- "subtotal": subtotal
123
+ }
124
+
125
+ ]
126
+
127
+ }
114
128
 
115
129
  ```
116
130
 

1

書式の改善

2017/05/30 16:28

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -20,17 +20,61 @@
20
20
 
21
21
  [
22
22
 
23
- {"title":"パーカー","price":"10000","id":"1","manufacture":"mont-bell","quantity":2},
23
+ {
24
24
 
25
- {"title":"ジャケット","price":"13924","id":"3","manufacture":"Marmot","quantity":1},
25
+ "id": "1",
26
26
 
27
- {"title":"S/S","price":"3856","id":"4","manufacture":"THE","quantity":1}
27
+ "manufacture": "mont-bell",
28
+
29
+ "price": "10000",
30
+
31
+ "quantity": 2,
32
+
33
+ "title": "パーカー"
34
+
35
+ },
36
+
37
+ {
38
+
39
+ "id": "3",
40
+
41
+ "manufacture": "Marmot",
42
+
43
+ "price": "13924",
44
+
45
+ "quantity": 1,
46
+
47
+ "title": "ジャケット"
48
+
49
+ },
50
+
51
+ {
52
+
53
+ "id": "4",
54
+
55
+ "manufacture": "THE",
56
+
57
+ "price": "3856",
58
+
59
+ "quantity": 1,
60
+
61
+ "title": "S/S"
62
+
63
+ }
28
64
 
29
65
  ]
30
66
 
31
67
  user json
32
68
 
69
+ {
70
+
71
+ "user_id": "2",
72
+
73
+ "user_name": "hoge",
74
+
33
- {"user_id":"2","user_name":"hoge","user_zip_code":"231-8359"}
75
+ "user_zip_code": "231-8359"
76
+
77
+ }
34
78
 
35
79
  subtotal
36
80