我的检查答案按钮不起作用,我的代码中有什么问题吗?

时间:2017-05-31 21:38:18

标签: javascript html css

我正在做一个多项选择测验,每个问题只有一个正确的答案。我的问题是,当我点击“检查答案”时,如果我的所有答案都正确,它只会显示我的警报框。我如何计算是非?

        <!doctype html>
<title>emp_quiz</title>
<html>
<meta name="viewport" content="width=device-width">
    <meta name="description" content="ISSG App">
<style>
body {
  font-family: sans-serif;
}

label:hover {
  color: blue;
}
</style>

<h1>Information Systems Security Quiz</h1>

<p>1. Which of the following is the transforming of data into an unreadable format that seems to be not readily understandable, so as to hide it from outsiders?<br>
<br><label><input id="radio1A" name="question1" type="radio"> Decryption</label>
<br><label><input id="radio1B" name="question1" type="radio"> HTTP</label>
<br><label><input id="radio1C" name="question1" type="radio"> Encryption</label>
<br><label><input id="radio1D" name="question1" type="radio"> Digital Certificate</label>

<p>2. For email attachment files, with which of the following extension do we have to pay special attention?
<br><label><input id="radio2A" name="question2" type="radio"> .bmp, .gif</label>
<br><label><input id="radio2B" name="question2"  type="radio"> .wav, .wmp</label>
<br><label><input id="radio2C" name="question2"  type="radio"> .exe, .com</label>
<br><label><input id="radio2D" name="question2"  type="radio"> .txt, .rtf</label>

<p>3. Which of the following is NOT typically included in a security policy?<br>
<br><label><input id="radio3A" name="question3" type="radio"> Roles and responsibilities of different parties for making the policy effective.</label>
<br><label><input id="radio3B" name="question3" type="radio"> Information resources to be protected.</label>
<br><label><input id="radio3C" name="question3" type="radio"> Minimum measures to protect information resources.</label>
<br><label><input id="radio3D" name="question3" type="radio"> Description of specific technologies used.</label>

<p>4. Which of the following is NOT one of the general considerations for securing the wireless network?<br>
<br><label><input id="radio4A" name="question4" type="radio"> Disable wireless connection when it is not in use.</label>
<br><label><input id="radio4B" name="question4" type="radio"> Turn on resource sharing protocols for your wireless interface card.</label>
<br><label><input id="radio4C" name="question4" type="radio"> Keep your wireless network interface card drivers up-to-date.</label>
<br><label><input id="radio4D" name="question4" type="radio"> Turn off ad hoc mode networking.</label>

<p>5. What is worm?<br>
<br><label><input id="radio5A" name="question5" type="radio"> It is a type of virus that specifically looks for and removes another virus.</label>
<br><label><input id="radio5B" name="question5" type="radio"> It is a program that spreads over network. Unlike a virus, a worm does not attach itself to a host program.</label>
<br><label><input id="radio5C" name="question5" type="radio"> It is a software that displays advertising banners while the program is running.</label>
<br><label><input id="radio5D" name="question5" type="radio"> It is a computer software that detects and cleans spyware.</label>

<p>6. When handling personal password, which of the following is NOT an appropriate action?<br>
<br><label><input id="radio6A" name="question6" type="radio"> Do not disclose your password.</label>
<br><label><input id="radio6B" name="question6" type="radio"> Change your password periodically to prevent password hacking.</label>
<br><label><input id="radio6C" name="question6" type="radio"> Do not store your password in the browser.</label>
<br><label><input id="radio6D" name="question6" type="radio"> Use your personal information for your password, such as your date of birth, to help you remembering it easily</label>

<p>7. Which of the following is NOT a threat resulting from using weak password for your PC and email account and seldom changing it?<br>
<br><label><input id="radio7A" name="question7" type="radio"> Unauthorised data access.</label>
<br><label><input id="radio7B" name="question7" type="radio"> Unauthorised dial-in access.</label>
<br><label><input id="radio7C" name="question7" type="radio"> Failure of communication services.</label>
<br><label><input id="radio7D" name="question7" type="radio"> Theft and fraud.</label>

<p>8. Which of the followings are NOT malicious codes?<br>
<br><label><input id="radio8A" name="question8" type="radio"> Viruses.</label>
<br><label><input id="radio8B" name="question8" type="radio"> Hash.</label>
<br><label><input id="radio8C" name="question8" type="radio"> Trojan horse.</label>
<br><label><input id="radio8D" name="question8" type="radio"> Worms.</label>

<p>9.  A proxy firewall filters at the ________.<br>
<br><label><input id="radio9A" name="question9" type="radio"> physical layer.</label>
<br><label><input id="radio9B" name="question9" type="radio"> application layer.</label>
<br><label><input id="radio9C" name="question9" type="radio"> data link layer.</label>
<br><label><input id="radio9D" name="question9" type="radio"> network layer
.</label>

<p>10.  An unauthorised user is a network _______ issue.<br>
<br><label><input id="radio10A" name="question10" type="radio"> Performance.</label>
<br><label><input id="radio10B" name="question10" type="radio"> Reliability.</label>
<br><label><input id="radio10C" name="question10" type="radio"> Security.</label>
<br><label><input id="radio10D" name="question10" type="radio"> All the above.</label>

<p>11. Which term describes hardware or sofware that protects your computer or network from probing or malicious users?<br>
<br><label><input id="radio11A" name="question11" type="radio"> Router.</label>
<br><label><input id="radio11B" name="question11" type="radio"> Firewall.</label>
<br><label><input id="radio11C" name="question11" type="radio"> Protocol.</label>
<br><label><input id="radio11D" name="question11" type="radio"> Spyware.</label>

<p>12. Which of the following are the basic components of a computer-based information system<br>
<br><label><input id="radio12A" name="question12" type="radio"> Upstream, Downstream, Internal.</label>
<br><label><input id="radio12B" name="question12" type="radio"> Computers, Information Technology, Hardware, People.</label>
<br><label><input id="radio12C" name="question12" type="radio"> Software, Hardware, Database, Network, Procedures, People.</label>
<br><label><input id="radio12D" name="question12" type="radio"> People, Management, Data, Information, Software, Hardware.</label>

<p>13. Which of the following means keeping the organisation's data safe, from things such as theft, modification and/or destruction?<br>
<br><label><input id="radio13A" name="question13" type="radio"> Data Integrity.</label>
<br><label><input id="radio13B" name="question13" type="radio"> Data Security.</label>
<br><label><input id="radio13C" name="question13" type="radio"> Data Armour.</label>
<br><label><input id="radio13D" name="question13" type="radio"> Information Protection.</label>

<p>14. A database is a groups of related _________ ?<br>
<br><label><input id="radio14A" name="question14" type="radio"> Files.</label>
<br><label><input id="radio14B" name="question14" type="radio"> Records.</label>
<br><label><input id="radio14C" name="question14" type="radio"> Fields.</label>
<br><label><input id="radio14D" name="question14" type="radio"> Attributes.</label>

<p>15. A connecting system that permits different computers to share resources is called _________ ?<br>
<br><label><input id="radio15A" name="question15" type="radio"> Procedures.</label>
<br><label><input id="radio15B" name="question15" type="radio"> Wifi.</label>
<br><label><input id="radio15C" name="question15" type="radio"> Internet.</label>
<br><label><input id="radio15D" name="question15" type="radio"> Network.</label>

<p>16. Which of the following describes Malware?<br>
<br><label><input id="radio16A" name="question16" type="radio"> A type of software used to access the internet.</label>
<br><label><input id="radio16B" name="question16" type="radio"> A virus.</label>
<br><label><input id="radio16C" name="question16" type="radio"> Software which is specifically designed to disrupt, damage, or gain authorized access to a computer system.</label>
<br><label><input id="radio16D" name="question16" type="radio"> Hardware which is specifically designed to disrupt, damage, or gain authorized access to a computer system.</label>

<p>17. Two methods of physical data security include:<br>
<br><label><input id="radio17A" name="question17" type="radio"> Locking doors and drawers of where data is stored.</label>
<br><label><input id="radio17B" name="question17" type="radio"> Using passwords and access levels.</label>
<br><label><input id="radio17C" name="question17" type="radio"> Locking backup copies and using firewalls.</label>
<br><label><input id="radio17D" name="question17" type="radio"> Using firewalls and encryption.</label>

<p>18. Data encryption is:<br>
<br><label><input id="radio18A" name="question18" type="radio"> Is software form of safeguarding of data.</label>
<br><label><input id="radio18B" name="question18" type="radio"> Is very effective in safeguarding data.</label>
<br><label><input id="radio18C" name="question18" type="radio"> Involves putting data into a secret code so that if accessed it is meaningless to anyone not having the key to decrypt it with.</label>
<br><label><input id="radio18D" name="question18" type="radio"> All of the above.</label>

<p>19. Piracy is:<br>
<br><label><input id="radio19A" name="question19" type="radio"> Is legal if one makes copies of software for himself only.</label>
<br><label><input id="radio19B" name="question19" type="radio"> Is illegal copying of software which may be for personal use or for sale.</label>
<br><label><input id="radio19C" name="question19" type="radio"> Is impossible if one used product activation techniques.</label>
<br><label><input id="radio19D" name="question19" type="radio"> Refers to the stealing of data from protected systems.</label>

<p>20. Which one of the following can protect a computer from the risk of
unwanted emails?<br>
<br><label><input id="radio20A" name="question20" type="radio"> Anti-spam software.</label>
<br><label><input id="radio20B" name="question20" type="radio"> Anti-virus software.</label>
<br><label><input id="radio20C" name="question20" type="radio"> Anti-spyware software.</label>
<br><label><input id="radio20D" name="question20" type="radio"> PC diagnostic software.</label>

<p><button id="checkButton">Check Answers</button>
<script>

function checkAnswers() {
  var score = 0;

  if (radio1C.checked) {
    score ++;
  }

  }

  if (radio2C.checked) {
    score ++;
  }

  if (radio3D.checked) {
    score ++;
  }

  if (radio4B.checked) {
    score ++;
  }

    if (radio5B.checked) {
    score ++;
  }

    if (radio6D.checked) {
    score ++;
  }

    if (radio7C.checked) {
    score ++;
  }

  if (radio8B.checked) {
    score ++;
  }

  if (radio9B.checked) {
    score ++;
  }

    if (radio10C.checked) {
    score ++;
  }

  if (radio11B.checked) {
    score ++;
  }

  if (radio12C.checked) {
    score ++;
  }

  if (radio13B.checked) {
    score ++;
  }

  if (radio14A.checked) {
    score ++;
  }

  if (radio15D.checked) {
    score ++;
  }

  if (radio16C.checked) {
    score ++;
  }

  if (radio17A.checked) {
    score ++;
  }

  if (radio18D.checked) {
    score ++;
  }

  if (radio19B.checked) {
    score ++;
  }

  if (radio20B.checked) {
    score ++;
  }
  alert('You scored:  ' + score)
}
checkButton.onclick = checkAnswers;
</script>
</html>

我总共有20个问题。我是否需要写一个else语句,否则如果??任何帮助表示赞赏:)

1 个答案:

答案 0 :(得分:0)

此示例是您的代码(减少一些语法错误)。它按照你的意愿工作,所以我不能100%确定错误是什么或是什么。也许这些语法错误之一就是问题所在,尽管根据您所描述的内容,这种错误很不可能。

&#13;
&#13;
function checkAnswers() {
  var score = 0;

  if (radio1C.checked) {
    score ++;
  }

  if (radio2C.checked) {
    score ++;
  }

  if (radio3D.checked) {
    score ++;
  }

  if (radio4B.checked) {
    score ++;
  }

    if (radio5B.checked) {
    score ++;
  }

    if (radio6D.checked) {
    score ++;
  }

    if (radio7C.checked) {
    score ++;
  }

  if (radio8B.checked) {
    score ++;
  }

  if (radio9B.checked) {
    score ++;
  }

    if (radio10C.checked) {
    score ++;
  }

  if (radio11B.checked) {
    score ++;
  }

  if (radio12C.checked) {
    score ++;
  }

  if (radio13B.checked) {
    score ++;
  }

  if (radio14A.checked) {
    score ++;
  }

  if (radio15D.checked) {
    score ++;
  }

  if (radio16C.checked) {
    score ++;
  }

  if (radio17A.checked) {
    score ++;
  }

  if (radio18D.checked) {
    score ++;
  }

  if (radio19B.checked) {
    score ++;
  }

  if (radio20B.checked) {
    score ++;
  }
  alert('You scored:  ' + score)
}
checkButton.onclick = checkAnswers;
&#13;
body {
  font-family: sans-serif;
}

label:hover {
  color: blue;
}
&#13;
<h1>Information Systems Security Quiz</h1>

<p>1. Which of the following is the transforming of data into an unreadable format that seems to be not readily understandable, so as to hide it from outsiders?<br>
<br><label><input id="radio1A" name="question1" type="radio"> Decryption</label>
<br><label><input id="radio1B" name="question1" type="radio"> HTTP</label>
<br><label><input id="radio1C" name="question1" type="radio"> Encryption</label>
<br><label><input id="radio1D" name="question1" type="radio"> Digital Certificate</label>

<p>2. For email attachment files, with which of the following extension do we have to pay special attention?
<br><label><input id="radio2A" name="question2" type="radio"> .bmp, .gif</label>
<br><label><input id="radio2B" name="question2"  type="radio"> .wav, .wmp</label>
<br><label><input id="radio2C" name="question2"  type="radio"> .exe, .com</label>
<br><label><input id="radio2D" name="question2"  type="radio"> .txt, .rtf</label>

<p>3. Which of the following is NOT typically included in a security policy?<br>
<br><label><input id="radio3A" name="question3" type="radio"> Roles and responsibilities of different parties for making the policy effective.</label>
<br><label><input id="radio3B" name="question3" type="radio"> Information resources to be protected.</label>
<br><label><input id="radio3C" name="question3" type="radio"> Minimum measures to protect information resources.</label>
<br><label><input id="radio3D" name="question3" type="radio"> Description of specific technologies used.</label>

<p>4. Which of the following is NOT one of the general considerations for securing the wireless network?<br>
<br><label><input id="radio4A" name="question4" type="radio"> Disable wireless connection when it is not in use.</label>
<br><label><input id="radio4B" name="question4" type="radio"> Turn on resource sharing protocols for your wireless interface card.</label>
<br><label><input id="radio4C" name="question4" type="radio"> Keep your wireless network interface card drivers up-to-date.</label>
<br><label><input id="radio4D" name="question4" type="radio"> Turn off ad hoc mode networking.</label>

<p>5. What is worm?<br>
<br><label><input id="radio5A" name="question5" type="radio"> It is a type of virus that specifically looks for and removes another virus.</label>
<br><label><input id="radio5B" name="question5" type="radio"> It is a program that spreads over network. Unlike a virus, a worm does not attach itself to a host program.</label>
<br><label><input id="radio5C" name="question5" type="radio"> It is a software that displays advertising banners while the program is running.</label>
<br><label><input id="radio5D" name="question5" type="radio"> It is a computer software that detects and cleans spyware.</label>

<p>6. When handling personal password, which of the following is NOT an appropriate action?<br>
<br><label><input id="radio6A" name="question6" type="radio"> Do not disclose your password.</label>
<br><label><input id="radio6B" name="question6" type="radio"> Change your password periodically to prevent password hacking.</label>
<br><label><input id="radio6C" name="question6" type="radio"> Do not store your password in the browser.</label>
<br><label><input id="radio6D" name="question6" type="radio"> Use your personal information for your password, such as your date of birth, to help you remembering it easily</label>

<p>7. Which of the following is NOT a threat resulting from using weak password for your PC and email account and seldom changing it?<br>
<br><label><input id="radio7A" name="question7" type="radio"> Unauthorised data access.</label>
<br><label><input id="radio7B" name="question7" type="radio"> Unauthorised dial-in access.</label>
<br><label><input id="radio7C" name="question7" type="radio"> Failure of communication services.</label>
<br><label><input id="radio7D" name="question7" type="radio"> Theft and fraud.</label>

<p>8. Which of the followings are NOT malicious codes?<br>
<br><label><input id="radio8A" name="question8" type="radio"> Viruses.</label>
<br><label><input id="radio8B" name="question8" type="radio"> Hash.</label>
<br><label><input id="radio8C" name="question8" type="radio"> Trojan horse.</label>
<br><label><input id="radio8D" name="question8" type="radio"> Worms.</label>

<p>9.  A proxy firewall filters at the ________.<br>
<br><label><input id="radio9A" name="question9" type="radio"> physical layer.</label>
<br><label><input id="radio9B" name="question9" type="radio"> application layer.</label>
<br><label><input id="radio9C" name="question9" type="radio"> data link layer.</label>
<br><label><input id="radio9D" name="question9" type="radio"> network layer
.</label>

<p>10.  An unauthorised user is a network _______ issue.<br>
<br><label><input id="radio10A" name="question10" type="radio"> Performance.</label>
<br><label><input id="radio10B" name="question10" type="radio"> Reliability.</label>
<br><label><input id="radio10C" name="question10" type="radio"> Security.</label>
<br><label><input id="radio10D" name="question10" type="radio"> All the above.</label>

<p>11. Which term describes hardware or sofware that protects your computer or network from probing or malicious users?<br>
<br><label><input id="radio11A" name="question11" type="radio"> Router.</label>
<br><label><input id="radio11B" name="question11" type="radio"> Firewall.</label>
<br><label><input id="radio11C" name="question11" type="radio"> Protocol.</label>
<br><label><input id="radio11D" name="question11" type="radio"> Spyware.</label>

<p>12. Which of the following are the basic components of a computer-based information system<br>
<br><label><input id="radio12A" name="question12" type="radio"> Upstream, Downstream, Internal.</label>
<br><label><input id="radio12B" name="question12" type="radio"> Computers, Information Technology, Hardware, People.</label>
<br><label><input id="radio12C" name="question12" type="radio"> Software, Hardware, Database, Network, Procedures, People.</label>
<br><label><input id="radio12D" name="question12" type="radio"> People, Management, Data, Information, Software, Hardware.</label>

<p>13. Which of the following means keeping the organisation's data safe, from things such as theft, modification and/or destruction?<br>
<br><label><input id="radio13A" name="question13" type="radio"> Data Integrity.</label>
<br><label><input id="radio13B" name="question13" type="radio"> Data Security.</label>
<br><label><input id="radio13C" name="question13" type="radio"> Data Armour.</label>
<br><label><input id="radio13D" name="question13" type="radio"> Information Protection.</label>

<p>14. A database is a groups of related _________ ?<br>
<br><label><input id="radio14A" name="question14" type="radio"> Files.</label>
<br><label><input id="radio14B" name="question14" type="radio"> Records.</label>
<br><label><input id="radio14C" name="question14" type="radio"> Fields.</label>
<br><label><input id="radio14D" name="question14" type="radio"> Attributes.</label>

<p>15. A connecting system that permits different computers to share resources is called _________ ?<br>
<br><label><input id="radio15A" name="question15" type="radio"> Procedures.</label>
<br><label><input id="radio15B" name="question15" type="radio"> Wifi.</label>
<br><label><input id="radio15C" name="question15" type="radio"> Internet.</label>
<br><label><input id="radio15D" name="question15" type="radio"> Network.</label>

<p>16. Which of the following describes Malware?<br>
<br><label><input id="radio16A" name="question16" type="radio"> A type of software used to access the internet.</label>
<br><label><input id="radio16B" name="question16" type="radio"> A virus.</label>
<br><label><input id="radio16C" name="question16" type="radio"> Software which is specifically designed to disrupt, damage, or gain authorized access to a computer system.</label>
<br><label><input id="radio16D" name="question16" type="radio"> Hardware which is specifically designed to disrupt, damage, or gain authorized access to a computer system.</label>

<p>17. Two methods of physical data security include:<br>
<br><label><input id="radio17A" name="question17" type="radio"> Locking doors and drawers of where data is stored.</label>
<br><label><input id="radio17B" name="question17" type="radio"> Using passwords and access levels.</label>
<br><label><input id="radio17C" name="question17" type="radio"> Locking backup copies and using firewalls.</label>
<br><label><input id="radio17D" name="question17" type="radio"> Using firewalls and encryption.</label>

<p>18. Data encryption is:<br>
<br><label><input id="radio18A" name="question18" type="radio"> Is software form of safeguarding of data.</label>
<br><label><input id="radio18B" name="question18" type="radio"> Is very effective in safeguarding data.</label>
<br><label><input id="radio18C" name="question18" type="radio"> Involves putting data into a secret code so that if accessed it is meaningless to anyone not having the key to decrypt it with.</label>
<br><label><input id="radio18D" name="question18" type="radio"> All of the above.</label>

<p>19. Piracy is:<br>
<br><label><input id="radio19A" name="question19" type="radio"> Is legal if one makes copies of software for himself only.</label>
<br><label><input id="radio19B" name="question19" type="radio"> Is illegal copying of software which may be for personal use or for sale.</label>
<br><label><input id="radio19C" name="question19" type="radio"> Is impossible if one used product activation techniques.</label>
<br><label><input id="radio19D" name="question19" type="radio"> Refers to the stealing of data from protected systems.</label>

<p>20. Which one of the following can protect a computer from the risk of
unwanted emails?<br>
<br><label><input id="radio20A" name="question20" type="radio"> Anti-spam software.</label>
<br><label><input id="radio20B" name="question20" type="radio"> Anti-virus software.</label>
<br><label><input id="radio20C" name="question20" type="radio"> Anti-spyware software.</label>
<br><label><input id="radio20D" name="question20" type="radio"> PC diagnostic software.</label>

<p><button id="checkButton">Check Answers</button>
&#13;
&#13;
&#13;