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
function doCheckPopup(formName, viewTarget, valueTarget, requestUrl) {
str_id = document.getElementsByName(valueTarget)[0].value;
id_array = str_id.split(",");
requestUrl = requestUrl + "?r=" + Math.round(Math.random() * 10000);
// TODO IEの場合は、背景の灰色は使わない。
// TODO IEの場合は、position: absolute;を指定して、大体同じに見えるようにする。
// TODO requestUrlに指定されたファイルから、jsonデータを受け取ってHTMLを生成する。
// 以下内容はテスト用サンル。
$.getJSON(requestUrl, function(json){
//console.log(json);
var type = "id";
var display = "title";
if (valueTarget == "tags") {
type ="tag";
display = "tag";
}
// if (valueTarget == "sponser_id") {
// type ="id";
// }
// if (valueTarget == "genre_id") {
// type ="id";
// }
var html_data = '';
html_data += '<table class="candidatetable">';
if (json.length == 0) {
html_data += '<td class="no_popup_result"><font color="#ff0000">无数据。</font></td></tr>';
} else if (json.length % 2 == 0) {
for(var i=0; i<json.length; i++){
var check_txt_left = '';
var check_txt_right = '';
html_data += '<tr>';
if(in_array(json[i][type], id_array)) {
check_txt_left = " checked";
}
if(in_array(json[(i+1)][type], id_array)) {
check_txt_right = " checked";
}
html_data += '<td align="left" nowrap><label><input type="checkbox" name="id_array[]" value="' + json[i][type] + '"' + check_txt_left + '>' + json[i][display] + '</label></td>';
html_data += '<td align="left" nowrap><label><input type="checkbox" name="id_array[]" value="' + json[(i+1)][type] + '"' + check_txt_right + '>' + json[(i+1)][display] + '</label></td>';
html_data += '</tr>';
i++;
}
} else {
for(var i=0; i<json.length-1; i++){
var check_txt_left = '';
var check_txt_right = '';
html_data += '<tr>';
if(in_array(json[i][type], id_array)) {
check_txt_left = " checked";
}
if(in_array(json[(i+1)][type], id_array)) {
check_txt_right = " checked";
}
html_data += '<td align="left" nowrap><label><input type="checkbox" name="id_array[]" value="' + json[i][type] + '"' + check_txt_left + '>' + json[i][display] + '</label></td>';
html_data += '<td align="left" nowrap><label><input type="checkbox" name="id_array[]" value="' + json[(i+1)][type] + '"' + check_txt_right + '>' + json[(i+1)][display] + '</label></td>';
html_data += '</tr>';
i++;
}
check_txt_left = '';
if(in_array(json[(json.length-1)][type], id_array)) {
check_txt_left = " checked";
}
html_data += '<tr><td align="left" nowrap><label><input type="checkbox" name="id_array[]" value="' + json[(json.length-1)][type] + '"' + check_txt_left + '>' + json[(json.length-1)][display] + '</label></td><td></td></tr>';
}
html_data += '</table>';
html_data += '<table width=100%>';
html_data += '<tr>';
html_data += '<td align="center" nowrap><button class="el-button height_30 el-button--primary" onClick="setCheckboxValue("' + viewTarget + '", "' + valueTarget + '", "' + requestUrl + '", "' + formName + '");" >确定</button></td>';
html_data += '</tr>';
html_data += '</table>';
doSelectPopup(html_data);
})
}