I am making an online quiz (school project) and basically I have 4 radio buttons (the options; multiple choice) and then an answer button. What I want is for the user to answer and submit it and then have javascript check the answer. I then want it to display an appropriate "correct" or "incorrect" below. This is what I have so far:
Expand|Select|Wrap|Line Numbers
- <html xmlns='http://www.w3.org/1999/xhtml'>
- <head>
- <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
- <title>Networking Quiz :: #1</title>
- <link href='core-style.css' rel='stylesheet' type='text/css' />
- <link href='sub_style.css' rel='stylesheet' type='text/css' />
- <script type='text/javascript'>
- function check() {
- if(document.form1.term.value=='Answer'){
- document.getElementById('correct').style.display='block';
- }else{
- document.getElementById('incorrect').style.display='block';
- }
- }
- </script>
- </head>
- <body>
- <center>
- <div id='content'>
- <div id='body'>
- <div id='question'>
- 1/39
- </div>
- <hr width='90%'>
- <div class='body_head'>
- Definition
- </div>
- <div class='main_text'>
- Used to connect to an ethernet network.
- </div>
- <div class='body_head'>
- Terms
- </div>
- <div class='review_text'>
- <form name='form1' id='terms' method='get' action=''>
- <input type='radio' name='term' value='Answer'>Network Interface Card (NIC)<br />
- <input type='radio' name='term' value='2'>Bluetooth<br />
- <input type='radio' name='term' value='3'>Voice Over Internet Protocol (VoIP)<br />
- <input type='radio' name='term' value='4'>Internet
- <p><input type='button' value='Answer!' name='answer' onclick='check();'></p>
- </form>
- </div>
- </div>
- <hr width='90%'>
- <div id='correct' style="display:none;">
- <div id='answer'>
- Correct Correct
- </div>
- <div id='button'>
- <a href='switch.php'>Next</a>
- </div>
- </div>
- <div id='incorrect' style="display:none;">
- <div id='answer'>
- Incorrect!!!! Incorrect!!!!!
- </div>
- <div id='button'>
- <a href='switch.php'>Next</a>
- </div>
- </div>
- </div>
- </center>
- </body>
- </html>