You are here: irt.org | FAQ | JavaScript | Form | Q1574 [ previous next ]
Try something like:
<script language="JavaScript"><!-- var answers = new Array(10); var correct = new Array('yes','no','yes','perhaps'....); function compareAndShow() { var text = 'You did the following:<br>' for (i=0;i<10;i++) { text += '<br>Answer ' + (i+1) + 'was '; if (answers[i] == correct[i]) text += 'correct'; else text += 'incorrect'; } var winid = window.open('','newwin'); winid.document.open(); winid.document.write(text); winid.document.close(); } //--></script> <form> <input type="radio" name="q0" onClick="answers[0] = 'yes'">Yes <input type="radio" name="q0" onClick="answers[0] = 'no'">No <br> <input type="radio" name="q2" onClick="answers[1] = 'yes'">Yes <input type="radio" name="q1" onClick="answers[1] = 'no'">No <input type="radio" name="q1" onClick="answers[1] = 'maybe'">Maybe <input type="radio" name="q1" onClick="answers[1] = 'none'">None of your business <br> <input type="radio" name="q2" onClick="answers[2] = 'yes'">Yes <input type="radio" name="q2" onClick="answers[2] = 'no'">No . . . <input type="button" onClick="compareAndShow()" VALUE="View Results"> </form>