このエラーが発生するUncaught ReferenceError:calculatePriceがHTMLInputElement.onclickで定義されていません。未捕捉ReferenceErrorを取得する
私は既にこのエラーに関する他の回答を見ており、どれもうまくいきませんでした。私は体や頭でスクリプトを定義しようとしましたが、違いはありませんでした。私はまた、私はソリューションに比べて、私はそれを接続する機能とボタンが正しいと思うので、私はそれがなぜそれが私がそれを押して動作していないのか分からない。
<html>
<head>
<link href="style/myStyles.css" type="text/css" rel="stylesheet">
<title> The Printing Company </title>
</head>
<body>
<script type="text/javascript"></script>
<script>
function calculatePrice() {
var quantity, type, price
quantity = document.getElementById("qty").value;
type = document.getElementById("cardstype").value;
if (type.includes("Basic"){
price = 10*(quantity/100);
} else if (type.includes("Medium"){
price = 15*(quantity/100);
} else if (type.includes("High"){
price = 20*(quantity/100);
}
alert("Your order will cost " + price + " GBP.");
}
</script>
<form action="form.php" method="post">
<label >Company Name</label><br>
<input name="name" type="text" required /><br>
<br>
<label>Contact email</label><br>
<input name="email" type="email" required /><br>
<br>
<label>Business Card type</label><br>
<select name="cardstype" id="cardstype">
<option value="" disabled selected>-Select Card Quality-</option>
<option value="Basic Quality">Basic Quality</option>
<option value="Medium Quality">Medium Quality</option>
<option value="High Quality">High Quality</option>
</select><br>
<br>
<label>Business Cards quantity</label><br>
<input name="qty" id ="qty" type="number" required Onchange = '
if(!(this.value >= 100 && this.value <= 1000)) {
//alert the user that they have made a mistake
alert(this.value + " is not a valid quantity. Minimun quantity per order: 100 and maximum: 1000.");
this.value=""; //clears the text box
}'><br>
<br>
<input type="button" name="Price" value="Calculate Price" onclick="calculatePrice()"/>
<input type="submit" value="Submit Order"/>
</form>
</html>
誰でも手助けできますか?
投票:
は例の作業typoは他のユーザーに役立つものではありません。 –
こんにちは、私はスペルの間違いを修正しましたが、何も修正しませんでした –
ああ、実際には、私はそれらを指摘するために私の答えを編集します。 –