[問題] 想請問一個 JavaScript 讀入 .js 檔的問題
以下是我的程式
主程式
<html>
<head>
<title>Sample</title>
<script type = "text/javascript" src = "common.js"> </script>
</head>
<body>
<form>
<input type = "text" name = "num1" value = ""> <br>
<input type = "text" name = "num2" value = ""> <br>
<input type = "button" value = "兩個值的相乘"
onClick = "alert(multi(this.form.num1.value, this.form.num2.value))"> <br>
</form>
</body>
</html>
外部檔案 (common.js)
function multi (n1, n2)
{
result = parseFloat(n1) * parseFloat(n2);
return result;
}
──────────────────────────────────────
這是照書上打的 輸入兩值 然後用 ALERT 跳出結果
但是用火狐跑的時候 錯誤主控台會出現 「illegal character」 的錯誤
若把 黃色處的 type 改成 language 後 可以去掉上面的錯誤
但是點按鈕後後 錯誤主控台會說 「multi is not defined」 也沒有 ALERT 跳出
請問版友們
這個程式出了什麼問題嗎
如果可以的話麻煩抽空回覆我 感激不盡 :)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.241.114
→
08/26 17:50, , 1F
08/26 17:50, 1F
※ 編輯: Leavesb 來自: 140.113.241.114 (08/26 19:44)
推
08/26 20:46, , 2F
08/26 20:46, 2F
→
08/26 20:51, , 3F
08/26 20:51, 3F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章