JavaScript implementation Click on the list of items in real time statistical amount of the method

Source: Internet
Author: User

This article illustrates the method of real time statistical amount of a JavaScript implementation click on a list of items. Share to everyone for your reference. The implementation methods are as follows:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66-67 <! 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> Merchandise List statistic amount </title> <style type=" Text/css "> Body,div,p margin:0; padding : 0; font-size:14px; } #sumMoney {font-size:26px font-weight:bold; color:red} </style> <script type= "Text/javascript" >// Select and fully clear function Checkall () {var chkitems = Document.getelementsbyname ("item"); for (var i = 0; i < chkitems.length; i++ ) {chkitems[i].checked = event.srcElement.checked;} calculatemoney (); //Statistics All selected product amount function Calculatemoney () {var sum = 0; var chkitems = Document.getelementsbyname ("item"); for (var i = 0 ; i < chkitems.length; i++) {if (chkitems[i].checked) {sum + = parseint (Chkitems[i].value);}} var summoneyobj = document.getElementById ("SumMo Ney "); summoneyobj.innerhtml = "Total Amount:"+ Sum;}  //For each product check box plus automatic statistics function inievent () {var chkitems = Document.getelementsbyname ("item"); for (var i = 0; i < Chkitems.length; i++) {Chkitems[i].onclick = Calculatemoney;}} </script> </head> <body onload= "inievent ()" > <div id= "Divmain" > <p><input type= " CheckBox "Name=" Select All "onclick=" Checkall () "/> Select </p> <p><input type=" checkbox "Name=" Item "value=" 2999 "/>¥2999 haier/Haier kfr-35gw/03gjc12-ds</p> <p><input type=" checkbox "Name=" Item "value=" 2256 "/>¥ 2,256 Day Cat Spring Festival aux/Ox kfr-35gw/sfa+2</p> <p><input type= "checkbox" Name= "Item" value= "2799"/>¥2799 Gree/ Gree kfr-26g (26556) fnde-3</p> <p><input type= "checkbox" Name= "Item" value= "2008"/>¥2008 aux/Ox kfr-25gw/sfa+2</p> <p><input type= "checkbox" Name= "Item" value= "2598"/>¥2598 hisense/Hisense KFR-35GW/ ef11s3</p> <p><input type= "checkbox" Name= "Item" value= "1877"/>¥1877 TCL Kfrd-25gw/de22</p> <p><input type= "checkbox" Name= "Item" value= "2398"/>¥2398 kelon/Kelon kfr-35gw/efvcs3</p> <p><input type= "checkbox" Name= "Item" value= "1999"/>¥1999 TCL kfrd-35gw/fc23</p> <p>< Input type= "checkbox" Name= "onclick=" Checkall ()/> Select all </p> <p><span id= "Summoney" > Total amount: </ span></p> </div> </body> </html>

The

wants this article to help you with your JavaScript programming.

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.