Native JS implementation of shopping cart prices and Total price statistics

Source: Internet
Author: User

1<! DOCTYPE html>2"en">34<meta charset="UTF-8">5<title>Document</title>6<script>7Window.onload=function () {8         varAin=document.queryselectorall ('input');9         varAem=document.queryselectorall ('em');Ten         varAi=document.queryselectorall ('I'); One          for(varI=0; i<ain.length;i++){ A  - (function (index) { -                 if(ain[index].value=='0'){ theDelete localstorage['a'+index]; -                  } -ain[i].oninput=function () { -Ai[index].innerhtml=parsefloat (aem[index].innerhtml) *parsefloat (ain[index].value); +localstorage['a'+index]=parsefloat (aem[index].innerhtml) *parsefloat (ain[index].value); -                      + storage (); A                 }; at  - }) (i); -              -        } - function Storage () { -                varArr=[]; in function Findarr () { -                     for(varNameinchlocalstorage) { to Arr.push (Localstorage[name]); +                      -                 } the                 returnarr; *             } $             varD=Findarr ();Panax Notoginseng             varp=0; -              for(varI=0; i<d.length;i++){ the                 varP=number (D[i]) +p; +Div1.innerhtml='Total Price:'+p; A             } the         } +         -     }; $</script> $ -<body> -<div> the<p> Product Name: Mild feeling Sword spectrum </p> -<input type=" Number"min="0"Value="0">Wuyi<em> -$</em><br><br> the<i></i> -  Wu</div> -<div> About<p> Product Name: Nine Yin Sutra </p> $<input type=" Number"min="0"Value="0"> -<em> -$</em><br><br> -<i></i> -  A</div> +<div> the<p> Product Name: Taijiquan Spectrum </p> -<input type=" Number"min="0"Value="0"> $<em> -$</em><br><br> the<i></i> the  the</div> the<div id="Div1">0</div> -</body> in

Native JS implementation of shopping cart prices and Total price statistics

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.