复制代码代码如下:
<! doctype html>
<html>
<head>
<title> mycart1.html </title>
<meta http-equiv = "คำหลัก" content = "keyword1, keyword2, keyword3">
<meta http-equiv = "คำอธิบาย" content = "นี่คือหน้าของฉัน">
<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">
ฟังก์ชั่น jisuan (obj) {
var total = 0;
var fruits = document.getElementsByName ("ผลไม้");
สำหรับ (var i = 0; i <fruits.length; i ++) {
ถ้า (ผลไม้ [i]. ตรวจสอบ) {
ทั้งหมด += parsefloat (ผลไม้ [i] .value);
-
-
mySpan.innerText = total + "元";
-
</script>
</head>
<body>
<อินพุต type = "ช่องทำเครื่องหมาย" name = "fruit" value = "10" onclick = "jisuan (นี่)"> 苹果 10 元 <br/>
<อินพุต type = "ช่องทำเครื่องหมาย" name = "fruit" value = "20" onclick = "jisuan (นี่)"> 香蕉 20 元 <br/>
<อินพุต type = "ช่องทำเครื่องหมาย" name = "fruit" value = "30" onclick = "jisuan (นี่)"> 西瓜 30 元 <br/>
<อินพุต type = "ช่องทำเครื่องหมาย" name = "fruit" value = "40" onclick = "jisuan (นี่)"> 栗子 40 元 <br/>
<อินพุต type = "ช่องทำเครื่องหมาย" name = "fruit" value = "50" onclick = "jisuan (นี่)"> 哈密瓜 50 元 <br/> <br/>
总价格是: <span id = "myspan"> 0 元 </span>
</body>
</html>