<div class="codetitle"> <span><a style="CURSOR: pointer" data="45444" class="copybut" id="copybut45444" onclick="doCopy('code45444')"><u>複製代碼</u></a></span>代碼如下:</div> <div class="codebody" id="code45444"> <br> <br> <br> <br><title>MyCart1.html</title> <br><br><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <br><meta http-equiv=" description" content="這是我的頁面"> <br><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <br><br><!-- <link rel="stylesheet" type="text/css" href="./styles.css">--> <br> <br><br>function jisuan(obj){ <br><br>var Total = 0; <br>var Fruits = document.getElementsByName("fruit"); <br>for(var i=0;i<fruits.length>if(fruits[i].checked){ <br>total = parseFloat(fruits[i].value); <br>} <br>} <br>myspan.innerText = 總計"元"; <br>} <br>腳本> <br>頭> <br><br> <br><input type="checkbox" name="fruit" value="10" onclick=" jisuan(this)">蘋果10元<br>> <br><input type="checkbox" name="fruit" value="20" onclick="jisuan(this)">香蕉20元<br> > <br><input type="checkbox" name="fruit" value="30" onclick="jisuan(this)">西瓜30元<br>> <br><input type="checkbox" name="fruit" value="40" onclick="jisuan(this)">栗子40元<br>> <br><input type="checkbox" name="fruit" value="50" onclick="jisuan( this)">哈密瓜50元<br><br><br>; <br>總價格為:<span id="myspan">0元</span> <br>身體> <br> <br></fruits.length> </div> <br><img src="http://files.jb51.net/file_images/article/201401/20140126155233.png?201402615533" alt="購物車選中得到價格實現範例_javascript技巧" >