JSQL client-based score statistics Implementation Method

Source: Internet
Author: User

Copy codeThe Code is as follows:
<! 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>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> Marks Count </title>
<Script type = "text/javascript" src = "../src/YESBRAIN. js"> </script>
<Script type = "text/javascript" src = "../src/JSQL. js"> </script>
<Script type = "text/javascript" src = "../src/JSQL-Memory.js"> </script>
<Script type = "text/javascript" src = "../src/JSQL-DOM.js"> </script>
<Style>
# Marks input {
Width: 100px;
}
</Style>
</Head>
<Body>
<Center>
<H1> Marks Count <P>
<Button onclick = "insertline ();"> Add one line </button>
<Button onclick = "savemarks ();"> Save Changes </button>
<Span> By <span>
<Select id = "byfield">
<Option value = "chinese" selected = "selected"> Chinese </option>
<Option value = "math"> Math </option>
<Option value = "english"> English </option>
</Select>
<Select id = "ascdesc">
<Option value = "desc" selected = "selected"> Desc </option>
<Option value = "asc"> Asc </option>
</Select>
<Button onclick = "order ();"> Order </button>
</P>
<Form name = "marks" id = "marks">
<Span> Name: </span>
<Input type = "text" id = "name [1]" value = "zhangsan">
<Span> Sex: </span>
<Input type = "text" id = "sex [1]" value = "female">
<Span> Chinese: </span>
<Input type = "text" id = "chinese [1]" value = "96">
<Span> Math: </span>
<Input type = "text" id = "math [1]" value = "94">
<Span> English: </span>
<Input type = "text" id = "english [1]" value = "98">
<Br>
</Form>
</Center>
<Script type = "text/javascript">
Var marks = [
{
Name: 'lisi ',
Sex: 'female ',
Chinese: '88 ',
Math: '90 ',
English: '92'
},
{
Name: 'wangwu ',
Sex: 'female ',
Chinese: '92 ',
Math: '80 ',
English: '82'
},
{
Name: 'lilei ',
Sex: 'female ',
Chinese: '93 ',
Math: '88 ',
English: '87'
},
{
Name: 'hanmeimei ',
Sex: 'male ',
Chinese: '97 ',
Math: '92 ',
English: '000000'
},
{
Name: 'hangzhou ',
Sex: 'male ',
Chinese: '92 ',
Math: '93 ',
English: '90'
}
];

Function addto (index, name, sex, chinese, math, english ){
"Insert into marks (nodename, innerHTML) values ('span ', 'name:')" .fordom(cmd.exe cute ();
("Insert into marks (nodename, type, id, value) values ('input', 'text', 'name [" + (index) + "] ', '"+ name +"') "2.16.fordom(cmd.exe cute ();
"Insert into marks (nodename, innerHTML) values ('span ', 'sex:')" .fordom(cmd.exe cute ();
("Insert into marks (nodename, type, id, value) values ('input', 'text', 'sex [" + (index) + "] ', '"+ sex +"') "2.16.fordom(cmd.exe cute ();
"Insert into marks (nodename, innerHTML) values ('span ', 'Chinese:')" .fordom(cmd.exe cute ();
("Insert into marks (nodename, type, id, value) values ('input', 'text', 'Chinese [" + (index) + "] ', '"+ chinese +"') "2.16.fordom(cmd.exe cute ();
"Insert into marks (nodename, innerHTML) values ('span ', 'math:')" .fordom(cmd.exe cute ();
("Insert into marks (nodename, type, id, value) values ('input', 'text', 'math [" + (index) + "] ', '"+ math +"') "2.16.fordom(cmd.exe cute ();
"Insert into marks (nodename, innerHTML) values ('span ', 'English:')" .fordom(cmd.exe cute ();
("Insert into marks (nodename, type, id, value) values ('input', 'text', 'English [" + (index) + "] ', '"+ english +"') "2.16.fordom(cmd.exe cute ();
("Insert into marks (nodename) values ('br ')" Fig (cmd.exe cute ();
};

For (var I = 0; I <marks. length; I ++ ){
Addto (I + 2, marks [I]. name, marks [I]. sex, marks [I]. chinese, marks [I]. math, marks [I]. english );
};

Function insertline (){
Var count = "select count (*) as Count from marks where id like 'name % '". ForDOM (). query ();
Var index = count [0]. Count + 1;
Addto (index ,"","","","","");
};

Function dellastline (){
Var count = "select count (*) as Count from marks where id like 'name % '". ForDOM (). query ();
Var index = count [0]. Count;
("Delete from marks where id like '% [" + index + "]'" pai.fordom(cmd.exe cute ();
};

"Create table savedmarks". execute ();

Function savemarks (){
Var names = ("select value from marks where id like 'name % '"). ForDOM (). query ();
Var sexs = ("select value from marks where id like 'sex % '"). ForDOM (). query ();
Var chineses = ("select value from marks where id like 'Chinese % '"). ForDOM (). query ();
Var maths = ("select value from marks where id like 'math % '"). ForDOM (). query ();
Var englishs = ("select value from marks where id like 'English % '"). ForDOM (). query ();
"Delete from savedmarks". execute ();
For (var I = 0; I <names. length; I ++ ){
("Insert into savedmarks (name, sex, chinese, math, english) values ('" + names [I]. value + "','" + sexs [I]. value + "'," + chineses [I]. value + "," + maths [I]. value + "," + englishs [I]. value + ")" cmd.exe cute ();
};
// Alert (savedmarks );
};

Function orderby (field, asc ){
Savemarks ();
Var marks = ("select * from savedmarks order by" + field + "" + asc). query ();
"Delete from marks" .fordom(cmd.exe cute ();
For (var I = 0; I <marks. length; I ++ ){
Addto (I + 2, marks [I]. name, marks [I]. sex, marks [I]. chinese, marks [I]. math, marks [I]. english );
};
};
Function order (){
Var byfield = document. getElementById ("byfield"). value;
Var ascdesc = document. getElementById ("ascdesc"). value;
Orderby (byfield, ascdesc );
};
</Script>
</Body>
</Html>

It mainly uses four JS libraries. YESBRAIN. js is the base library and JSQL. js is the interface. JSQL-Memory.js and JSQL-DOM are the SQL Implementation of javascript Objects Array and Html DOM by JSQL.

Jsql javascript

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.