复制代码代码如下:
<! Doctype html>
<html>
<adal>
<Title> Mycart1.html </Title>
<meta http-equiv = "keywords" contenu = "keyword1, keyword2, keyword3">
<méta http-equiv = "Description" content = "Ceci est ma page">
<meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8">
<! - <link rel = "Stylesheet" type = "text / css" href = "./ styles.css"> ->
<script lingots = "javascript" type = "text / javascript">
fonction jisuan (obj) {
var total = 0;
var fruits = document.getElementsByName ("fruit");
pour (var i = 0; i <fruits.length; i ++) {
if (fruits [i] .checked) {
total + = parsefloat (fruits [i] .value);
}
}
myspan.innertext = total + "元";
}
</cript>
</ head>
<body>
<input type = "checkbox" name = "fruit" value = "10" onclick = "jisuan (this)"> 苹果 10 元 <br/>
<input type = "checkbox" name = "fruit" value = "20" onclick = "jisuan (this)"> 香蕉 20 元 <br/>
<input type = "checkbox" name = "fruit" value = "30" onclick = "jisuan (this)"> 西瓜 30 元 <br/>
<input type = "checkbox" name = "fruit" value = "40" onclick = "jisuan (this)"> 栗子 40 元 <br/>
<input type = "checkbox" name = "fruit" value = "50" onclick = "jisuan (this)"> 哈密瓜 50 元 <br/> <br/>
总价格是 : <span id = "myspan"> 0 元 </span>
</docy>
</html>