質問編集履歴
5
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -72,4 +72,16 @@
|
|
72
72
|
0:[object Object]
|
73
73
|
1:[object Object]
|
74
74
|
2:[object Object]
|
75
|
-
3:[object Object]
|
75
|
+
3:[object Object]
|
76
|
+
|
77
|
+
###試したこと3
|
78
|
+
試したこと2 の最後のeach部分を以下のように修正。
|
79
|
+
|
80
|
+
var result = $('#textarea').val();
$.each(output, function (key, object) {
$.each(object, function (title, text) {
if (result[title] !== '') {
result += (title + ':' + text + '\n');
}
})
});
$('#textarea').val(result);
|
81
|
+
|
82
|
+
・結果
|
83
|
+
title : text
|
84
|
+
title : text
|
85
|
+
title : text
|
86
|
+
title : text
|
87
|
+
期待した結果にはなったが、もっとスマートな方法はありますでしょうか。
|
4
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -43,4 +43,33 @@
|
|
43
43
|
output: Array[0]
|
44
44
|
radioButtn:"らじお"
|
45
45
|
length:0
selected:Array[0](未選択状態)
|
46
|
-
string:"てきすと"
|
46
|
+
string:"てきすと"
|
47
|
+
|
48
|
+
###試したこと2
|
49
|
+
```
|
50
|
+
function output() {
|
51
|
+
|
52
|
+
// Textareaへの出力用配列
|
53
|
+
var output = [];
|
54
|
+
|
55
|
+
// radioButton のラベルタイトル
|
56
|
+
output.push({'radioButton' : radioButton.text()} );
|
57
|
+
|
58
|
+
// 複数選択selectboxで選択されている値(text)
|
59
|
+
var selectedText = [];
$selected = $Field_2.find('#selected option:selected');
$selected.each(function () {
selectedText.push($(this).text());
});
|
60
|
+
output.push({'selected' : selectedText});
|
61
|
+
|
62
|
+
// 普通のtext
|
63
|
+
output.push({'string' : string.text()});
|
64
|
+
|
65
|
+
// 出力箇所
|
66
|
+
$.each(output, function (key, text) {
$('#textarea').append(key + ' : ' + text + "\n");
});
|
67
|
+
|
68
|
+
```
|
69
|
+
|
70
|
+
・結果
|
71
|
+
出力はされているがキーが配列番号になってしまう。
|
72
|
+
0:[object Object]
|
73
|
+
1:[object Object]
|
74
|
+
2:[object Object]
|
75
|
+
3:[object Object]
|
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -34,4 +34,13 @@
|
|
34
34
|
```
|
35
35
|
|
36
36
|
###試したこと
|
37
|
-
Modal内の各要素を配列化することはできている。
|
37
|
+
Modal内の各要素を配列化することはできている。
|
38
|
+
|
39
|
+
|
40
|
+
[追記]
|
41
|
+
・each直前のoutputの中身
|
42
|
+
|
43
|
+
output: Array[0]
|
44
|
+
radioButtn:"らじお"
|
45
|
+
length:0
selected:Array[0](未選択状態)
|
46
|
+
string:"てきすと"
|
2
本文修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,6 +8,9 @@
|
|
8
8
|
・実現したいこと
|
9
9
|
Modalにて設定した項目・内容をTextareaに出力したい。
|
10
10
|
|
11
|
+
###わからないこと
|
12
|
+
出力処理のeachに入らず、出力されない
|
13
|
+
|
11
14
|
###該当のソースコード
|
12
15
|
```
|
13
16
|
function output() {
|
1
本文修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
###前提・実現したいこと
|
2
2
|
・前提
|
3
3
|
POST送信用フォーム:Form
|
4
|
-
|
4
|
+
Formの中にある「詳細フィールド(textarea)」:Textarea
|
5
|
-
|
5
|
+
Formと同じ画面内にある別フォームModal:Modal
|
6
6
|
Modalの中身:ラジオボタン・text・セレクトリスト
|
7
7
|
|
8
8
|
・実現したいこと
|