Quiz – Confirm Answers before Submitting

[Total: 0    Average: 0/5]

This example shows how to have a quiz in the form of a radio selection for each qustion.

Body Code:

<form name=exf1>
Q1:<input type=radio name=r1 value="A">A
<input type=radio name=r1 value="B">B
<input type=radio name=r1 value="C">C
<input type=radio name=r1 value="D">D<BR>
Q2:<input type=radio name=r2 value="A">A
<input type=radio name=r2 value="B">B
<input type=radio name=r2 value="C">C
<input type=radio name=r2 value="D">D<BR>
<input type=button value="Submit" onclick=x()>
function y(_i) {
  var _ret = "";
  for (var _a=0; _a < eval("document.exf1.r"+_i+".length"); _a++)
    if (eval("document.exf1.r"+_i+"["+_a+"].checked")) {
	  _ret = eval("document.exf1.r"+_i+"["+_a+"].value");
  return (_ret);
function x() {
  var _s="Ok to proceed with the following?n";
  _s += "Q1: "+y(1)+"n";
  _s += "Q2: "+y(2);
  var _ans = confirm(_s);
  if (_ans) document.exf1.submit();

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *