Shopping cart selected to get a price implementation example
<!DOCTYPE html><html><head><title>MyCart1.html</title><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="this is my page"><meta http-equiv="content-type" content="text/html; charset=UTF-8"><!--<link rel="stylesheet" type="text/css" href="./styles.css">--><script language = "javascript" type = "text/javascript">function jisuan(obj){var total = 0;var fruits = document.getElementsByName("fruit");for(var i=0;i<fruits.length;i++){if(fruits[i].checked){total += parseFloat(fruits[i].value);}}myspan.innerText = total + " yuan ";}</script></head><body><input type = "checkbox" name = "fruit" value = "10" onclick = "jisuan(this)"> apple 10 yuan <br/><input type = "checkbox" name = "fruit" value = "20" onclick = "jisuan(this)"> banana 20 yuan <br/><input type = "checkbox" name = "fruit" value = "30" onclick = "jisuan(this)"> watermelon 30 yuan <br/><input type = "checkbox" name = "fruit" value = "40" onclick = "jisuan(this)"> chestnuts 40 yuan <br/><input type = "checkbox" name = "fruit" value = "50" onclick = "jisuan(this)"> Hami melon 50 yuan <br/><br/> The total price is: <span id = "myspan">0 yuan </span></body></html>