[Javascript] Save as Incomplete or Submit

Teresa L Cannon Teresa.Cannon at ipaper.com
Thu Jul 26 15:07:05 CDT 2001


I've got the generic vailidation routine for the survey form, but how do I
get the form to "Save as Incomplete" or "Submit Final Survey"?

Here's what I've got so far:

Basically, if the value of the radio button at bottom before the submit
button is set as default "Save as Incomplete", value of radio1="0"

     if so, do not even go through the routine below, but do go to the
"Survey-Script.asp" to input data so far into the database
     (later I will retrieve upon returning to this survey, that's my next
step after getting this to work).

Only go through the validation routine below if changed value of radio1
="1", Submit Final Survey.

How do I do this or is there a better way?
_____________________________________

function GoForm2(form)
{
  for (var e = 0; e < form.elements.length; e++)
  {
    var el = form.elements[e];
    if (el.type == 'radio')
    {
      var group = form[el.name];
      var checked = false;
      if (!group.length)
        checked = el.checked;
      else
        for (var r = 0; r < group.length; r++)
          if ((checked = group[r].checked))
            break;
      if (!checked)
      {
        alert('Please check one of the radio buttons on the next
question.');
        el.focus();
        return false;
      }
    }
    else if (el.type == 'checkbox')
    {
      var group = form[el.name];
      if (!group.length)
        checked = el.checked;
      else
        for (var r = 0; r < group.length; r++)
          if ((checked = group[r].checked))
            break;
        if (!checked)
        {
          alert('Please check one of the checkboxes on the next
question.');
          el.focus();
          return false;
          }
    }
    else
    {
     if (el.value == "" || el.value == null || el.value == " ")
      {
          alert('Please answer the next question.');
          el.focus();
          return false;
      }
    }
  }
  return true;
 }

...when it goes through this script above, then go to "Survey-Script.asp"
to save to the db.

......
<form action="Survey-Script.asp" name="Form2" id="Form2" method="post"
onsubmit="return GoForm2(this)">

.... survey questions here...


               <INPUT type="radio" id=rad1 name=radio1 value="0"
checked>Save as Incomplete
               <INPUT type="radio" id=rad2 name=radio1 value="1">Submit
Final Survey

               <input TYPE="submit" VALUE="Save Survey" Name="button1"><BR>





More information about the Javascript mailing list