Csdn Forum technical area average assignment function _ javascript skills

Source: Internet
Author: User
The technical area in the forum does not have the average score function. If it is inconvenient to split the score, I wrote an Internet Explorer 8, test OK 1 average score for each person in FF3.5 (only one score for repeated replies ):
Javascript: var t = function (tag, s) {return (s | document ). getElementsByTagName (tag) ;}; var n = function (name) {return document. getElementsByName (name)}; var total = t ("var") [0]. innerHTML-0; var scores = n ("tb_score"); var lz = t ("a", t ("var") [0]. parentNode) [0]. innerHTML; var c ={}; c [lz] = lz; for (var I = 0; I
Source code:

The Code is as follows:


Var t = function (tag, s) {return (s | document). getElementsByTagName (tag );};
Var n = function (name) {return document. getElementsByName (name )};
Var total = t ("var") [0]. innerHTML-0;
Var scores = n ("tb_score ");
Var lz = t ("a", t ("var") [0]. parentNode) [0]. innerHTML;
Var c = {};
C [lz] = lz;
For (var I = 0; I Var v = t ("a", scores [I]. parentNode) [0]. innerHTML;
If (! C [v]) {
C [v] = v;
Scores [I]. value = scores [I]. value-0 + 1;
Total --;
If (total = 0) break;
}
If (I = scores. length-1) {I =-1; c = {}; c [lz] = lz ;}
};
Alert ("OK ");


2 average score per floor:
Javascript: var t = function (tag, s) {return (s | document ). getElementsByTagName (tag) ;}; var n = function (name) {return document. getElementsByName (name)}; var total = t ("var") [0]. innerHTML-0; var scores = n ("tb_score"); var lz = t ("a", t ("var") [0]. parentNode) [0]. innerHTML; for (var I = 0; I
Source code:

The Code is as follows:


Var t = function (tag, s) {return (s | document). getElementsByTagName (tag );};
Var n = function (name) {return document. getElementsByName (name )};
Var total = t ("var") [0]. innerHTML-0;
Var scores = n ("tb_score ");
Var lz = t ("a", t ("var") [0]. parentNode) [0]. innerHTML;
For (var I = 0; I If (t ("a", scores [I]. parentNode) [0]. innerHTML! = Lz ){
Scores [I]. value = scores [I]. value-0 + 1;
Total --;
If (total = 0) break;
}
If (I = scores. length-1) I =-1;
};
Alert ("OK ");


Note: Put the above Code in the address bar of the finishing page and press Enter. It is only used once. Otherwise, a negative score will occur.
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.