复制代码 代码如下: Marks Count <BR>#marks input { <BR>width: 100px; <BR>} <BR> Marks Count Add one line Save Changes By Chinese Math English Desc Asc Order Name: Sex: Chinese: Math: English: <BR>var marks = [ <BR>{ <BR>name: 'Lisi', <BR>sex: 'Female', <BR>chinese: '88', <BR>math: '90', <BR>english: '92' <BR>}, <BR>{ <BR>name: 'Wangwu', <BR>sex: 'Female', <BR>chinese: '92', <BR>math: '80', <BR>english: '82' <BR>}, <BR>{ <BR>name: 'Lilei', <BR>sex: 'Female', <BR>chinese: '93', <BR>math: '88', <BR>english: '87' <BR>}, <BR>{ <BR>name: 'HanMeimei', <BR>sex: 'Male', <BR>chinese: '97', <BR>math: '92', <BR>english: '100' <BR>}, <BR>{ <BR>name: 'Wangjuan', <BR>sex: 'Male', <BR>chinese: '92', <BR>math: '93', <BR>english: '90' <BR>} <BR>]; <br><br>function addto(index,name,sex,chinese,math,english) { <BR>"insert into marks (nodename,innerHTML) values ('span','Name:')".ForDOM().execute(); <BR>("insert into marks (nodename,type,id,value) values ('input','text','name[" + (index) + "]','" + name + "')").ForDOM().execute(); <BR>"insert into marks (nodename,innerHTML) values ('span','Sex:')".ForDOM().execute(); <BR>("insert into marks (nodename,type,id,value) values ('input','text','sex[" + (index) + "]','" + sex + "')").ForDOM().execute(); <BR>"insert into marks (nodename,innerHTML) values ('span','Chinese:')".ForDOM().execute(); <BR>("insert into marks (nodename,type,id,value) values ('input','text','chinese[" + (index) + "]','" + chinese + "')").ForDOM().execute(); <BR>"insert into marks (nodename,innerHTML) values ('span','Math:')".ForDOM().execute(); <BR>("insert into marks (nodename,type,id,value) values ('input','text','math[" + (index) + "]','" + math + "')").ForDOM().execute(); <BR>"insert into marks (nodename,innerHTML) values ('span','English:')".ForDOM().execute(); <BR>("insert into marks (nodename,type,id,value) values ('input','text','english[" + (index) + "]','" + english + "')").ForDOM().execute(); <BR>("insert into marks (nodename) values ('br')").ForDOM().execute(); <BR>}; <br><br>for(var i=0; i<marks.length;i++) { <BR>addto(i+2,marks[i].name,marks[i].sex,marks[i].chinese,marks[i].math,marks[i].english); <BR>}; <br><br>function insertline() { <BR>var count = "select count(*) as Count from marks where id like 'name%'".ForDOM().query(); <BR>var index = count[0].Count + 1; <BR>addto(index,"","","","",""); <BR>}; <br><br>function dellastline() { <BR>var count = "select count(*) as Count from marks where id like 'name%'".ForDOM().query(); <BR>var index = count[0].Count; <BR>("delete from marks where id like '%["+ index +"]'").ForDOM().execute(); <BR>}; <br><br>"create table savedmarks".execute(); <br><br>function savemarks() { <BR>var names = ("select value from marks where id like 'name%'").ForDOM().query(); <BR>var sexs = ("select value from marks where id like 'sex%'").ForDOM().query(); <BR>var chineses = ("select value from marks where id like 'chinese%'").ForDOM().query(); <BR>var maths = ("select value from marks where id like 'math%'").ForDOM().query(); <BR>var englishs = ("select value from marks where id like 'english%'").ForDOM().query(); <BR>"delete from savedmarks".execute(); <BR>for(var i=0;i<names.length;i++) { <BR>("insert into savedmarks (name,sex,chinese,math,english) values ('"+ names[i].value +"','" + sexs[i].value + "'," + chineses[i].value + "," + maths[i].value + "," + englishs[i].value + ")").execute(); <BR>}; <BR>//alert(savedmarks); <BR>}; <br><br>function orderby(field,asc) { <BR>savemarks(); <BR>var marks = ("select * from savedmarks order by " + field + " " + asc).query(); <BR>"delete from marks".ForDOM().execute(); <BR>for(var i=0; i<marks.length;i++) { <BR>addto(i+2,marks[i].name,marks[i].sex,marks[i].chinese,marks[i].math,marks[i].english); <BR>}; <BR>}; <BR>function order() { <BR>var byfield = document.getElementById("byfield").value; <BR>var ascdesc = document.getElementById("ascdesc").value; <BR>orderby(byfield,ascdesc); <BR>}; <BR> 主要用到四个JS库,其中YESBRAIN.js是基库,JSQL.js是接口。JSQL-Memory.js和JSQL-DOM分别是JSQL对 javascript Objects Array 和 Html DOM 的 SQL 实现。jsql javascript