日期:2014-05-16 浏览次数:20364 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> //alert(1097 % 10); var Data = new Array(); var Data1 = new Array(); var yuShu = Data.length % 10; var HTML; function initialization() { var table = document.getElementById("table"); for (var i = 0; i < 10; i++) { var tr = document.createElement("tr"); var td = document.createElement("td"); var td1 = document.createElement("td"); td.id = "td"; td1.id = "td1"; tr.appendChild(td); tr.appendChild(td1); table.appendChild(tr); } HTML = table.innerHTML; } function initable() { var tableTD = document.getElementsByName("td"); var tableTD1 = document.getElementsByName("td1"); var sum = Data.length; for (var i = 0; i < 10; i++) { if (i >= Data.length) { break; } tableTD[i].innerHTML = Data1[sum-1]; tableTD1[i].innerHTML = Data[sum-1]; sum--; } } function show(b, o) { var tableTD = document.getElementsByName("td"); var tableTD1 = document.getElementsByName("td1"); for (var i = 0; i < 10; i++) { if (b >= Data.length) { tableTD[i].innerHTML = ""; tableTD1[i].innerHTML = ""; b++; } else { tableTD[i].innerHTML = Data1[b]; tableTD1[i].innerHTML = Data[b]; b++; } } } function fb(text) { Data1[Data.length] = Date(); Data[Data.length] = text; initable(); fenye(); } function fenye() { var div = document.getElementById("fy"); yuShu = Data.length % 10; var fenYeShu = (Data.length - yuShu) / 10; div.innerHTML = ""; for (var i = 1; i <= fenYeShu; i++) { var a = document.createElement("input"); a.type = "button"; a.onclick = spot; a.value = i + "0"; div.appendChild(a); //div.appendChild( ); } if (yuShu > 0) { var a = document.createElement("input"); a.type = "button"; a.onclick = spot; a.value = fenYeShu * 10 + yuShu; div.appendChild(a); } } function spot(event) { var obj = event.srcElement ? event.srcElement : event.target; if (obj.value % 10 > 0) { show(obj.value - yuShu, obj.value); } else { show(obj.value - 10, obj.value); } } </script> </head> <body onload="initialization()"> <input type="text" id="texts" /> <input type="button" onclick="fb(document.getElementById('texts').value)" value="发表评论"/> <table id="table" border="1"></table>