Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> JavaScript
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Wed Sep 10, 2008 11:04 am Reply with quote

I have a lengthy Peer Evaluation that students fill out on their team members.

I have 4 radio buttons each for each question under the following subjects: Cooperative Learning Skills, Self-Directed Learning, and Interpersonal Skills.

The options are Never, Sometimes, Often, and Always.

I want to make sure they choose one and not leave it blank.

I also have two feedback textarea for a "Qualitative Assessment" comment that they must fill out.

So far I am not getting any validation and the form is being submitted and values written to the table even though I am leaving some blank.

Here is my code:
Code:


OpenTable();
      echo "<form name = 'AddM2PeerEvals' method='post' action='modules.php?name=$module_name' onsubmit='return check_form_M2();'>\n";   
         
      echo"<table width=\"100%\" border=\"0\" cellpadding=\"3\">"
           ." <tr><td><b>Part One: Quanitative Assessment (Check only one box for each of these items)</b></td></tr>"
         . "</table>";
      echo"<table width=\"100%\" border=\"1\" cellpadding=\"3\">"
      ." <tr><td align=\"center\"><b>Cooperative Learning Skills</b></td><td align=\"center\"><b>Never</b></td><td align=\"center\"><b>Sometimes</b></td><td align=\"center\"><b>Often</b></td><td align=\"center\"><b>Always</b></td></tr>"      
        ."<tr><td width = '50%'>Arrives on time and remains with team during activites.</td><td align=\"center\"><input type = 'Radio' Name ='clskill_1' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_1' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_1' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_1' value= '0'</td></tr>"
      ."<tr><td width = '50%'>Demonstrates a good balance of active listening and participation.</td><td align=\"center\"><input type = 'Radio' Name ='clskill_2' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_2' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_2' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_2' value= '0'</td></tr>"
      ."<tr><td width = '50%'>Asks useful or probing questions.</td><td align=\"center\"><input type = 'Radio' Name ='clskill_3' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_3' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_3' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_3' value= '0'</td></tr>"
      ."<tr><td width = '50%'>Shares information and personal understanding.</td><td align=\"center\"><input type = 'Radio' Name ='clskill_4' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_4' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_4' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='clskill_4' value= '0'</td></tr>";           
        echo"</table>";   
      echo"<table width=\"100%\" border=\"1\" cellpadding=\"3\">"
      ." <tr><td align=\"center\"><b>Self-Directed Learning</b></td><td align=\"center\"><b>Never</b></td><td align=\"center\"><b>Sometimes</b></td><td align=\"center\"><b>Often</b></td><td align=\"center\"><b>Always</b></td></tr>"      
        ."<tr><td width = '50%'>Is well prepared for team activities.</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_1' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_1' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_1' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_1' value= '0'</td></tr>"
      ."<tr><td width = '50%'>Shows appropriate depth of knowledge.</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_2' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_2' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_2' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_2' value= '0'</td></tr>"
      ."<tr><td width = '50%'>Identifies limits of personal knowledge.</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_3' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_3' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_3' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_3' value= '0'</td></tr>"
      ."<tr><td width = '50%'>Is clear when explaining things to others.</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_4' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_4' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_4' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='sdskill_4' value= '0'</td></tr>";           
        echo"</table>";   
      echo"<table width=\"100%\" border=\"1\" cellpadding=\"3\">"
      ." <tr><td align=\"center\"><b>Interpersonal Skills</b></td><td align=\"center\"><b>Never</b></td><td align=\"center\"><b>Sometimes</b></td><td align=\"center\"><b>Often</b></td><td align=\"center\"><b>Always</b></td></tr>"      
        ."<tr><td width = '50%'>Gives useful feedback to others.</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_1' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_1' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_1' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_1' value= '0'</td></tr>"
      ."<tr><td width = '50%'>Accepts useful feedback from others.</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_2' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_2' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_2' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_2' value= '0'</td></tr>"
      ."<tr><td width = '50%'>Is able to listen and understand what others are saying.</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_3' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_3' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_3' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_3' value= '0'</td></tr>"
      ."<tr><td width = '50%'>Shows respect to the opinion and feelings of others.</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_4' value= '3'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_4' value= '2'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_4' value= '1'</td><td align=\"center\"><input type = 'Radio' Name ='ipskill_4' value= '0'</td></tr>";           
        echo"</table>";   
      echo "<br />\n";
   echo"<table width=\"100%\" border=\"0\" cellpadding=\"3\">"
           ." <tr><td><b>Part Two: Qualitative Assessment</b> (For each item, write <b>at least one sentence</b>, but <b>not more than three</b> sentences.)</b></td></tr>"
         . "</table>";      
      echo"<table width=\"100%\" border=\"1\" cellpadding=\"3\">"
      . "<tr><td align=\"left\"><b>1. What is the single most valuable contribution this person makes to your team?</b></td></tr>"
      . "<tr><td align=\"left\"><textarea id='qa_1_text' name ='qa_1_text' cols='120' colspan='1' rows='3'></textarea></td></tr>"
      . "<br />\n"
      . "<tr><td align=\"left\"><b>2. What is the single most important thing this person could do to more effectively help your team?</b></td></tr>"
      . "<tr><td align=\"left\"><textarea id='qa_2_text' name ='qa_2_text' cols='120' colspan='1' rows='3'></textarea></td></tr>"
      . "<tr><td colspan=\"3\" align=\"center\"><input type=\"Submit\" name=\"TLInsertM2PeerEvals\" value=\"Submit\"></td></tr>"
      . "</table>"
      ."<input type='hidden' name='op' value='TLInsertM2PeerEvals'>"
      . "<input type='hidden' name='UID' value='$UID'>\n"
      . "</form>";               
        CloseTable();


My custom_header.php file looks like this:
Code:


<script type="text/javascript">
//<![CDATA[
function check_form_M2() {
var clskill_1, clskill_2, clskill_3, clskill_4, sdskill_1, sdskill_2, sdskill_3, sdskill_4, ipskill_1, ipskill_2, ipskill_3, ipskill_4, qa_1_text, qa_2_text;
   
   if(clskill_1.value) == ''
   {
      alert('Please fill out all Cooperative Learning Skills');
      clskill_1.focus();
      return false;
   }
   else if(clskill_2.value) == ''
   {
      alert('Please fill out all Cooperative Learning Skills');
      clskill_2.focus();
      return false;
   }
   else if(clskill_3.value) == ''
   {
      alert('Please fill out all Cooperative Learning Skills');
      clskill_3.focus();
      return false;
   }
   else if(clskill_4.value) == ''
   {
      alert('Please fill out all Cooperative Learning Skills');
      clskill_4.focus();
      return false;
   }
   else if(sdskill_1.value) == ''
   {
      alert('Please fill out all Self-Directed Learning Skills');
      sdskill_1.focus();
      return false;
   }
   else if(sdskill_2.value) == ''
   {
      alert('Please fill out all Self-Directed Learning Skills');
      sdskill_2.focus();
      return false;
   }
   else if(sdskill_3.value) == ''
   {
      alert('Please fill out all Self-Directed Learning Skills');
      sdskill_3.focus();
      return false;
   }
   else if(sdskill_4.value) == ''
   {
      alert('Please fill out all Self-Directed Learning Skills');
      sdskill_4.focus();
      return false;
    }
   else if(ipskill_1.value) == ''
      {
      alert('Please fill out all Interpersonal Skills');
      ipskill_1.focus();
      return false;
    }   
    else if(ipskill_2.value) == ''
      {
      alert('Please fill out all Interpersonal Skills');
      ipskill_2.focus();
      return false;
    }   
    else if(ipskill_3.value) == ''
      {
      alert('Please fill out all Interpersonal Skills');
      ipskill_3.focus();
      return false;
    }   
    else if(ipskill_4.value) == ''
      {
      alert('Please fill out all Interpersonal Skills');
      ipskill_4.focus();
      return false;
    }    
   else if(qa_1_text.value) == ''
   {
      alert('Please enter all Qualitative Assessment feedback');
      qa_1_text.focus();
      return false;
   }
   else if(qa_2_text.value) == ''
   {
      alert('Please enter all Qualitative Assessment feedback');
      qa_2_text.focus();
      return false;
   }   
   else
   {                    
      return true;
   }
//]]>
</script>


</head>
</html>


The datatype for my radio buttons is set('0', '1', '2', '3') and the NULL value is set to No.

Do I need to allow NULL values to see if this works?
 
View user's profile Send private message Visit poster's website ICQ Number
Donovan







PostPosted: Wed Sep 10, 2008 11:53 am Reply with quote

Could I also do something like this:

Code:
echo "<form name = 'AddM2PeerEvals' method='post' action='modules.php?name=$module_name' onsubmit='return check_form_M2(this.form);'>\n";   


Then in custom_header.php do

Code:
if ( ( form.clskill_1[0].checked == false ) && ( form.clskill_1[1].checked == false ) && ( form.clskill_1[2].checked == false ) && ( form.clskill_1[3].checked == false ) ) { alert ( "Please fill out all Cooperative Learning Skills" ); return false; }


Does this seem easier?

I getting much of this from tutorials.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> JavaScript

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©