私はHTMLとJavaスクリプトを使用している新しいセキュリティ評価Webページに取り組んでいます。何らかの理由で、コードが正しく動作していません。ページの動作方法は、ユーザーに「はい」または「いいえ」と答えさせることです。ユーザーが完了すると、「送信」をクリックします。ページにはイエスと答えた質問の数と、ユーザーが評価を合格または不合格にした場合のメッセージが表示されます。しかし、私がsubmitをクリックすると、私は結果だけを見て、メッセージは見ません。メッセージを表示
フィードバックは高く評価されます。
function sumInputs() {
var text;
var score = document.getElementById("total").value;
if (score < 60) {
text = "You have failed the Assessment";
} else(score > 60) {
text = "You have passed the Assessment";
}
document.getElementById("demo").innerHTML = text;
}
function calcscore() {
var score = 0;
$(".calc:checked").each(function() {
score += parseInt($(this).val(), 10);
});
$("input[name=sum]").val(score)
}
$().ready(function() {
$(".calc").change(function() {
calcscore()
});
});
window.sumInputs = function() {
var inputs = $('.calc:checked'),
result = document.getElementById('total'),
sum = 0;
for (var i = 0; i < inputs.length; i++) {
sum += parseInt(inputs[i].value);
}
$('#total').val(sum);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<body>
<p id="demo"></p>
<h1>Security Assessment </h1>
<table>
<tr>
<th>PERSONNEL SECURITY</th>
</tr>
<tr>
<td>1. Does your staff wear ID badges?
<form>
Yes
<input class="calc" type="radio" name="radio1" value="1" /> No
<input class="calc" type="radio" name="radio1" value="0" /><br />
</td>
</tr>
<tr>
<td>2. Is a current picture part of the ID badge? Yes
<input class="calc" type="radio" name="radio2" value="1" /> No
<input class="calc" type="radio" name="radio2" value="0" /><br />
</td>
</tr>
<tr>
<td>3. Are authorized access levels and type (employee, contractor, visitor) identified on the Badge? Yes
<input class="calc" type="radio" name="radio3" value="1" /> No
<input class="calc" type="radio" name="radio3" value="0" /><br />
</form>
</td>
</tr>
</table>
Total : <input type="text" name="total" id="total" />
<input type="Submit" value="Submit" onclick="sumInputs()">
</body>
</html>
なぜ2つのHTML文書は、 – guest271314
私は構文エラーを修正始めるのでしょうか?質問であるあなたのコンソールを見てください。 – empiric