This is the JS Code used to calculate Zhejiang mobile phone bills.Code, Using the jquery framework.
First, you need to obtain the webpage containing the phone bill information, such99. htm:
For the JS file written in 99.htm, visit the 99.htm webpage.Source codeAdd the following code:
<SCRIPT type = "text/JavaScript" src = "../JS/jquery. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "../JS/chinamobile. js"> </SCRIPT>
The first line is to load jquery. JS, and the second line is to load the self-written JS file (Chinamobile. js).
The content of the chinamobile. js file is:
Function fluxconsume () // consumption: mobile data traffic or WLAN details {var table = $ ("tr. listtitle "). parent (); var trlist = table. eq (2 ). find ("tr. content2 "); var vsum = 0.0; trlist. each (function () {var IV = parsefloat ($ (this ). find ("TD: eq (7 )"). text (); If (! Isnan (IV) vsum + = IV;}); vsum = vsum. tofixed (2); // keep 2 decimal places (rounded to) Alert (vsum );}
Click the "calculate consumption" button in 99.htm to get the consumption value. --- The above fluxconsume () only calculates the traffic generated by mobile data. The code for calculating the voice fee and SMS fee is as follows:
Function voiceconsume () // voice consumption {var table = $ ("tr. listtitle "). parent (); var trlist = table. eq (0 ). find ("tr. content2 "); var vsum = 0.0; trlist. each (function () {var IV = parsefloat ($ (this ). find ("TD: eq (12 )"). text (); If (! Isnan (IV) vsum + = IV;}); vsum = vsum. tofixed (2); // retain 2 decimal places (rounded to) Alert (vsum);} function compute messageconsume () // message consumption {var table = $ ("tr. listtitle "). parent (); var trlist = table. eq (1 ). find ("tr. content2 "); var vsum = 0.0; trlist. each (function () {var IV = parsefloat ($ (this ). find ("TD: eq (7 )"). text (); If (! Isnan (IV) vsum + = IV;}); vsum = vsum. tofixed (2); // keep 2 decimal places (rounded to) Alert (vsum );}
Table. eq (XX) and $ (this). Find ("TD: eq (XXX)"). Text () in the functionXxAndXxxIt is related to the source code of the webpage and can be modified according to the actual situation.