<div class="codetitle"> <span><a style="CURSOR: pointer" data="38770" class="copybut" id="copybut38770" onclick="doCopy('code38770')"><u>コードをコピー</u></a></span> コードは次のとおりです:</div> <div class="codebody" id="code38770"> <br><!DOCTYPE html> <br><br><html xmlns="http://www.w3.org/1999/xhtml"> <br><head runat="server"> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <br><title></title> <br><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <br><script type="text/javascript"> <br>Array.prototype.filterRepeat = function () { <br>var res = [], hash = {}; <br>for (var i = 0, elem; (elem = this[i]) != null; i ) { <br>if (!hash[elem]) { <br>res.push(elem); <br>ハッシュ[elem] = true; <br>} <br>} <br>応答を返します。 <br>} <br>$(function () { <br>var json = [ <br>{ "SysName": "数据库", "SysGuid": "1", "CourseName": "SQL", "CourseGuid" ": "22"、"備考": "大sb"、"firstdate": "2013-1-1"、"firstresult": "合格"、"secdate": "2013-2-1"、"secresult" : "合格", "thirddate": "2013-3-1", "thirdresult": "合格" }, <br>{ "SysName": "数据库", "SysGuid": "1", "CourseName": "MySQL"、"CourseGuid": "23"、"備考": "IQ太低"、"firstdate": "2013-1-1"、"firstresult": "不合格"、"secdate": "2013- 2-1", "secresult": "不合格", "thirddate": "2013-3-1", "thirdresult": "合格" }, <br>{ "SysName": "数据库", "SysGuid" : "1"、"CourseName": "NoSQL"、"CourseGuid": "24"、"備考": "IQ太低"、"firstdate": "2013-1-1"、"firstresult": "不合格", "secdate": "2013-2-1", "secresult": "合格", "thirddate": "2013-3-1", "thirdresult": "合格" }, <br>{ "SysName" : "数据库"、"SysGuid": "1"、"CourseName": "Oracle"、"CourseGuid": "25"、"備考": "IQ太低"、"firstdate": "2013-1-1" , "firstresult": "不合格", "secdate": "2013-2-1", "secresult": "合格", "thirddate": "2013-3-1", "thirdresult": "合格" } , <br>{ "SysName": "ASP.NET", "SysGuid": "2", "CourseName": "基础", "CourseGuid": "43", "備考": "IQ太低", " firstdate": "2013-1-1"、"firstresult": "合格"、"secdate": "2013-2-1"、"secresult": "不合格"、"thirddate": "2013-3-1 ", "thirdresult": "合格" }, <br>{ "SysName": "ASP.NET", "SysGuid": "2", "CourseName": "高级", "CourseGuid": "44", "備考": "IQ太低"、"firstdate": "2013-1-1"、"firstresult": "合格"、"secdate": "2013-2-1"、"secresult": "不合格"、 "threedate": "2013-4-1", "thirdresult": "合格" }, <br>{ "SysName": "JavaScript", "SysGuid": "3", "CourseName": "基础", " CourseGuid": "54"、"備考": "IQ太低"、"firstdate": "2013-1-1"、"firstresult": "合格"、"secdate": "2013-2-1"、" secresult": "合格", "thirddate": "2013-5-1", "thirdresult": "合格" }, <br>{ "SysName": "JavaScript", "SysGuid": "3", "CourseName ": "高级", "CourseGuid": "67", "備考": "IQ太低", "firstdate": "2013-1-1", "firstresult": "不合格", "secdate": " 2013-2-1", "secresult": "合格", "thirddate": "2013-6-1", "thirdresult": "合格" }, <br>]; <br>createTable(json); <br><br>$("#btnsave").click(function () { <br>$("#ta").text(setDataXML()); <br>}); <br>}); <br>function createTable(json) { <br>var tb = $("#tb"); <br>var sys = 新しい配列; <br>for (var i = 0; i <json.length i>sys.push(json[i].SysName); <br>} <br>//过滤重复 <br>sys = sys.filterRepeat(); <br>var tr = null; <br>for (var j = 0 ; j <sys.length j>tr = "<tr style='text-align: left' class=gridborder id=p" j ">< ;tdcolspan=8>[-]" sys[j] "</td></tr>"; <br>for (var i = 0; i <json.length i>if (json[i].SysName == sys[j]) { <br>tr = "<trparent= p" j " style='text-align: center' pguid='" json[i].SysGuid "' cguid='" json[i].CourseGuid "'><td>" json[i].CourseName "</td><td>" setDate(json[i].firstdate) "</td><td>" setSelect(json[i].firstresult) "</td><td>" setDate(json[i].secdate) "</td><td>" setSelect(json[i].secresult) "</td><td>" setDate(json[i].thirddate) "</td><td>" setSelect(json[i].thirdresult) "</td><td>" setInput(json[i].備考) "</td></tr>" <br>} <br>} <br>} <br>tb.append(tr); <br>//設置行点击イベント <br>$("tr.gridborder").css("cursor", "pointer") <br>.toggle(function () { <br>var txt = $(this ).children().text(); <br>$(this).children().text(txt.replace("-", " ")); function () { <br>var txt = $(this).children().text(); <br>$(this).children().text(txt.replace(" ", "-")); .click(function () { <br>var id = $(this).attr("id"); <br>$(this).siblings("tr[parent='" id "']").toggle ();<br>}); <br>//設置选中变色 <br>$("tr[parent^=p]").toggle(function () { <br>$(this).attr('bgcolor', '#E3e4e5'); <br>}, function () { <br>$(this).attr('bgcolor', '#ffffff'); <br>}<br>function setSelect(obj) { <br>return "<select style='width:96%'><option value ='" obj "'>" obj "</option ><option value='合格'>合格</option><option value='不合格'>不合格</option></select>"; <br>} <br>function setDate(obj) { <br>return "<input style='width:96%' type='text' value='" obj "' />"; <BR>} <BR>function setInput(obj) { <BR>return "<input style='width:96%' type='text' value='" obj "' />"; <BR>} <BR>function setDataXML() { <BR>var dataxml = $("<DataXML></DataXML>"); <br>$("tr[parent^=p]").each(function () { <br>var item = $("<Course/>"); <br>var sysguid = $(this) .attr("pguid"); <br>var cguid = $(this).attr("cguid"); <br>var fdate = $(this).children().children().eq(0)。 val(); <br>var fresult = $(this).children().children().eq(1).val(); <br>var sdate = $(this).children().children() .eq(2).val(); <br>var sresult = $(this).children().children().eq(3).val(); <br>var tdate = $(this).children ().children().eq(4).val(); <br>var tresult = $(this).children().children().eq(5).val(); $(this).children().children().eq(6).val(); <br>item.attr("SysGuid", sysguid).attr("備考", コメント).attr("コースGUID" , cguid) <br>.attr("FirstDate", fdate).attr("FirstResult", fresult) <br>.attr("SecDate", sdate).attr("SecResult", sresult) <br>.attr ("ThirdDate", tdate).attr("ThirdResult", tresult); <br>dataxml.append(item) <br>}); <br>return dataxml[0].outerHTML; <br>} <br><br></script> <br></head> <br> <br><form id="form1" runat="server"> <br><div> <br><br><table id="tb" border="1" style="border-collapse: Collapse" width="100%"> <br> <br><tr style="text-align: center"> <br><td style="width: 100px">课程名</td> <br><br><td style="width: 120px">初検討時間</td> <br><td style="width: 120px">初考成绩</td> <br><td style="width: 120px">次検討時間</td> <br><td style="width: 120px">次検討成绩</td> <br><td style="width: 120px">清検討時間</td> <br><td style="width: 120px">清考成绩</td> <br><td style="width: 250px">备注</td> <br></tr> <br><br></tbody> <br></table> <br> </div> <br><input id="btnsave" type="button" value="保存" /> <br><textarea id="ta"cols="100" rows="20" ></textarea> <br><br></form> <br><br></body> <br></html> <br><br></json.length></sys.length></json.length> </div>