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); }) }