Zhejiang mobile phone bill calculation-JS Code

Source: Internet
Author: User

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.

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.