Radio Grid HTML Forms with Nag

Is current?: 
Yes

The radiogrid-nag template radiogrid-nag.htm is a type of HTML form that is a variant of the radiogrid.  The nag functionality uses Javascript code to alert the user if he or she has not responded to all items.  This nag alerts the user once, and after that, the user is free to proceed to the next task, even without completing the items.

The use of the fake button and the distinction between the fake button and real button is explained in the dropdown-nag entry. The onclick event handler in the fake button on line 149 is the function donag().  When the user clicks on the Continue button, donag() checks if the user had previously clicked this button.  If this is the first click and if the responses are incomplete then the user is alerted.  If this is the second click, or if the items have been completed, then the form is submitted using document.form1.submit().  The donag()for radiogrid is below, and the logic is very similar to the radio-nag template. All items are initialized to the missing value in lines 43-53.

<script type="text/javascript">

  var nnag=0;

  function donag() {

    nnag++;               // increment by 1

    var allanswered=true; // assume everything is complete

    if (document.form1.griditem1[0].checked) allanswered=false;

    if (document.form1.griditem2[0].checked) allanswered=false;

    if (document.form1.griditem3[0].checked) allanswered=false;

    if (document.form1.griditem4[0].checked) allanswered=false;

    if (document.form1.griditem5[0].checked) allanswered=false;

    if (document.form1.griditem6[0].checked) allanswered=false;

    if (document.form1.griditem7[0].checked) allanswered=false;

    if (document.form1.griditem8[0].checked) allanswered=false;

    if (document.form1.griditem9[0].checked) allanswered=false;if (!allanswered && nnag<=1)
     alert("Please answer all items.\nThis reminder will appear once.");

          else document.form1.submit();

   }

 </script>