Solved

Form results faulty

Posted on 2001-09-06
13
179 Views
Last Modified: 2008-03-06
I've got a form that adds some results, and emails them, but it is ommitting everthing from question5 in section 6 on. See it at http://www.extragravity.com/your_pq_observer.htm or below...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
  <HEAD>
       <TITLE></TITLE><META HTTP-EQUIV="Content-Type"
       CONTENT="text/html; charset=windows-1251"><STYLE TYPE="text/css">BODY {
      FONT: 10pt "Verdana"
}
H1 {
      FONT: bold 15pt/17pt "Arial"; COLOR: maroon
}
H2 {
      FONT: bold 13pt/15pt "Arial"; COLOR: blue
}
</STYLE><SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
<!--

// ** How to setup new questions **
// var questions? = new Array("MAIN QUESTION",
//                            "QUESTION 1",
//                            "QUESTION 2",
//                            "QUESTION 3",
//                            "QUESTION 4",
//                            "QUESTION 5");

var questions1 = new Array("How good is this person at understanding people?",
                           "He/she listens attentively to grasp what someone is thinking.",
                           "He/she takes notice of other people's body language to understand them better.",
                           "To avoid misunderstanding, he/she asks good questions to clarify what the speaker is saying.",
                           "He/she is able to sense what another person is feeling.",
                           "He/she can decipher the underlying reasons why people he/she knows acts the way they do.");

var questions2 = new Array("How good is this person at expressing their thoughts and feelings clearly?",
                           "He/she gives just enough detail so that he/she is understood.",
                           "People enjoy listening to him/her.",
                           "He/she can take something complicated and explain it clearly.",
                           "He/she says what he/she means and what he/she feels.",
                           "When he/she is not clear, he/she lets the other person ask questions rather then go on and on explaining himself/herself.");

var questions3 = new Array("How good is this person at asserting their needs?",
                           "He/she is decisive about what he/she will do or not do for others.",
                           "He/she speaks up when his/her needs are not being met.",
                           "He/she keeps calm and remains confident under pressure.",
                           "He/she stands his/her ground.",
                           "He/she can say no with grace and tact.");

var questions4 = new Array("How good is this person at exchanging feedback?",
                           "He/she gives appreciation and compliments freely.",
                           "When he/she criticizes people, he/she gives specific examples and offer suggestions for improvement.",
                           "To get different perspectives, he/she asks for feedback from a wide range of people.",
                           "He/she asks others for feedback to improve himself/herself, not to fish for compliments.",
                           "He/she listens to feedback he/she receive from others.");

var questions5 = new Array("How good is this person at influencing how others think and act?",
                           "He/she establishs rapport with people before trying to persuade them to do something.",
                           "He/she explores other people's viewpoints before trying to convince them of his/her own.",
                           "He/she gives compelling reasons for adopting his/her viewpoint.",
                           "People are not defensive when he/she gives advice.",
                           "He/she gives people time to mull over what he/she has presented to them.");

var questions6 = new Array("How good is this person at getting conflict resolved? ",
                           "He/she gets the tensions between the other person and himself/herself out on the table.",
                           "Right from the start, he/she seeks agreement over victory.",
                           "He/she learns all he/she can about the other person's needs and interests when negotiating.",
                           "He/she works to solve problems, not blame others, when they hit a stone wall.",
                           "When he/she reaches an agreement with someone, he/she makes sure they both stick to it.");

var questions7 = new Array("How good is this person at collaborating with others?",
                           "He/she requests help from others and give them assistance in return.",
                           "He/she pitches in when the group needs something done.",
                           "He/she focuses on other people's welfare as much as his/her own.",
                           "He/she keeps others informed about what he/she is doing if it affects them.",
                           "He/she helps to facilitate and coordinate the efforts of others.");

var questions8 = new Array("How good is this person at shifting gears?",
                           "When a relationship is not going well, he/she takes the initiative to do something about it.",
                           "He/she can see the patterns he/she falls into with other people.",
                           "Even if he/she is not at fault, he/she is open to making significant changes in his/her behavior, when necessary.",
                           "He/she is willing to take risks when they are called for.",
                           "He/she is resilient.  If things don't work out, he/she bounces back.");

var questions = new Array(questions1, questions2, questions3, questions4,
                          questions5, questions6, questions7, questions8);

function updateTotals(formObj, sectionVal){

var tempVal = 0;

//Update appropriate section
for (var y = 1; y < 6; y++){
 eval("tempVal += parseInt(formObj.value" + sectionVal + "_" + y + ".value);");
}

eval("formObj.subtotal" + sectionVal + ".value = tempVal;");

tempVal = 0;

// Update grandTotal
for (var x = 1; x < questions.length + 1; x++){
 eval("tempVal += parseInt(formObj.subtotal" + x + ".value);");
}

formObj.grandTotal.value = tempVal;

}

// -->
</SCRIPT><META CONTENT="Microsoft FrontPage 4.0" NAME="GENERATOR">
  </HEAD>
  <BODY>
       <H3 ALIGN="center">&nbsp;The PeopleSmart Scale (Observer)</H3>
       <FORM ACTION="http://www.activetraining.com/cgi-bin/mailer2.pl"
        METHOD="post">
            <P>The PeopleSmart Scale (Observer) can be used to give feedback about
              the interpersonal intelligence of someone you know. As you complete the scale,
              think about your direct experiences with the person you are rating as well as
              your observations of his/her skills with other people.</P>
            <P>Feedback is a gift. Choose wisely by being as objective as you can. It
              will not help the recipient if you hold back your perceptions, however positive
              or negative they are. You have a vantage point when observing this person that
              is unique.</P>
            <P>&nbsp;<INPUT NAME="for"> Name of person you are observing. </P>
            <P>&nbsp;<INPUT NAME="name"> Name of observer (your name, optional).
              <BR></P>
            <P>&nbsp;<INPUT NAME="sendto"> Email address to which results will be
              sent.<BR></P><SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
<!--

for (var x = 1; x < questions.length + 1; x++){
 var currQuestionArray = questions[x - 1];
 document.writeln("<h4>PeopleSmart Skill " + x + ": " + currQuestionArray[0] + "</h3>");
 document.writeln("<p>excellent = 4&nbsp;&nbsp;&nbsp;&nbsp;good = 3&nbsp;&nbsp;&nbsp;&nbsp;fair = 2&nbsp;&nbsp;&nbsp;poor = 1</p>");
 for (var y = 1; y < 6; y++){
   document.writeln("<input type=\"text\" name=\"value" + x + "_" + y +
"\" size=\"3\" value=\"0\" onBlur=\"updateTotals(this.form," + x + ");\"> " + y + ". " +
currQuestionArray[y] + "<br>");
 }
 document.writeln("<br><input type=\"text\" name=\"subtotal" + x
+ "\" value=\"0\" size=\"3\" onFocus=\"this.blur();\"><b> Subtotal for Skill "
+ x + "</b><br>");
}

for(j=0;j<=questions.length;j++)
{
for(k=0;k<=questions[j].length;k++)
{
document.write('<INPUT TYPE="HIDDEN" VALUE="' + questions[j][k] + '" NAME="sec_' + Number(j+1) + '_'

+ k + '">')
}}

// -->
</SCRIPT><BR><INPUT VALUE="0" NAME="grandTotal"> <B>Click in Box to see this
            person's score</B> <BR><BR><INPUT TYPE="reset" VALUE="Reset">
            <INPUT ONCLICK="this.form.submit()" TYPE="button" VALUE="send the results">
            </FORM>
       <P>&nbsp;</P> </BODY>
</HTML>
0
Comment
Question by:jgla
  • 7
  • 4
  • 2
13 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6463228
One bug is
for(j=0;j<=questions.length;j++)
should be
for(j=0;j<questions.length;j++)

Michel
0
 

Author Comment

by:jgla
ID: 6464579
Hmmm. Now the emailed results have an added line for a 6th question in each section, that reads: "undefined
They answered:     2

And sections 7 and 8 still don't record the numerical values...

See it at http://www.extragravity.com/your_pq_observer.htm
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6465438
Clean up your arrays!!!

Michel
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6465707
OK, here is a modified page to loop through the arrays and build your questions. From what I say before, it looks like you will need to adjust the script in your cgi to use counter starting with 0, not 1.  I have found that for myself it is much easier to use zero based series instead of any other index.

good luck, let me know if you really need to have cerain pieces start with something other than zero and I can put htem in for you.

davlun

*******  code starts here **********

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
  <HEAD>
       <TITLE></TITLE><META HTTP-EQUIV="Content-Type"
       CONTENT="text/html; charset=windows-1251"><STYLE TYPE="text/css">BODY {
      FONT: 10pt "Verdana"
}
H1 {
      FONT: bold 15pt/17pt "Arial"; COLOR: maroon
}
H2 {
      FONT: bold 13pt/15pt "Arial"; COLOR: blue
}
</STYLE><SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
<!--

// ** How to setup new questions **
// var questions? = new Array("MAIN QUESTION",
//                            "QUESTION 1",
//                            "QUESTION 2",
//                            "QUESTION 3",
//                            "QUESTION 4",
//                            "QUESTION 5");

var questions1 = new Array("How good is this person at understanding people?",
                           "He/she listens attentively to grasp what someone is thinking.",
                           "He/she takes notice of other people's body language to understand them better.",
                           "To avoid misunderstanding, he/she asks good questions to clarify what the speaker is saying.",
                           "He/she is able to sense what another person is feeling.",
                           "He/she can decipher the underlying reasons why people he/she knows acts the way they do.");

var questions2 = new Array("How good is this person at expressing their thoughts and feelings clearly?",
                           "He/she gives just enough detail so that he/she is understood.",
                           "People enjoy listening to him/her.",
                           "He/she can take something complicated and explain it clearly.",
                           "He/she says what he/she means and what he/she feels.",
                           "When he/she is not clear, he/she lets the other person ask questions rather then go on and on explaining himself/herself.");

var questions3 = new Array("How good is this person at asserting their needs?",
                           "He/she is decisive about what he/she will do or not do for others.",
                           "He/she speaks up when his/her needs are not being met.",
                           "He/she keeps calm and remains confident under pressure.",
                           "He/she stands his/her ground.",
                           "He/she can say no with grace and tact.");

var questions4 = new Array("How good is this person at exchanging feedback?",
                           "He/she gives appreciation and compliments freely.",
                           "When he/she criticizes people, he/she gives specific examples and offer suggestions for improvement.",
                           "To get different perspectives, he/she asks for feedback from a wide range of people.",
                           "He/she asks others for feedback to improve himself/herself, not to fish for compliments.",
                           "He/she listens to feedback he/she receive from others.");

var questions5 = new Array("How good is this person at influencing how others think and act?",
                           "He/she establishs rapport with people before trying to persuade them to do something.",
                           "He/she explores other people's viewpoints before trying to convince them of his/her own.",
                           "He/she gives compelling reasons for adopting his/her viewpoint.",
                           "People are not defensive when he/she gives advice.",
                           "He/she gives people time to mull over what he/she has presented to them.");

var questions6 = new Array("How good is this person at getting conflict resolved? ",
                           "He/she gets the tensions between the other person and himself/herself out on the table.",
                           "Right from the start, he/she seeks agreement over victory.",
                           "He/she learns all he/she can about the other person's needs and interests when negotiating.",
                           "He/she works to solve problems, not blame others, when they hit a stone wall.",
                           "When he/she reaches an agreement with someone, he/she makes sure they both stick to it.");

var questions7 = new Array("How good is this person at collaborating with others?",
                           "He/she requests help from others and give them assistance in return.",
                           "He/she pitches in when the group needs something done.",
                           "He/she focuses on other people's welfare as much as his/her own.",
                           "He/she keeps others informed about what he/she is doing if it affects them.",
                           "He/she helps to facilitate and coordinate the efforts of others.");

var questions8 = new Array("How good is this person at shifting gears?",
                           "When a relationship is not going well, he/she takes the initiative to do something about it.",
                           "He/she can see the patterns he/she falls into with other people.",
                           "Even if he/she is not at fault, he/she is open to making significant changes in his/her behavior, when necessary.",
                           "He/she is willing to take risks when they are called for.",
                           "He/she is resilient.  If things don't work out, he/she bounces back.");

var questions = new Array(questions1, questions2, questions3, questions4,
                          questions5, questions6, questions7, questions8);

function updateTotals(formObj, sectionVal)
{
      var tempVal = 0;

      //Update appropriate section
      for (var y = 1; y < 6; y++)
      {
            eval("tempVal += parseInt(formObj.value" + sectionVal + "_" + y + ".value);");
      }

      eval("formObj.subtotal" + sectionVal + ".value = tempVal;");

      tempVal = 0;

      // Update grandTotal
      for (var x = 1; x < questions.length + 1; x++)
      {
            eval("tempVal += parseInt(formObj.subtotal" + x + ".value);");
      }

      formObj.grandTotal.value = tempVal;
}

// -->
</SCRIPT><META CONTENT="Microsoft FrontPage 4.0" NAME="GENERATOR">
  </HEAD>
  <BODY>
       <H3 ALIGN="center">&nbsp;The PeopleSmart Scale (Observer)</H3>
       <FORM ACTION="http://www.activetraining.com/cgi-bin/mailer2.pl"
        METHOD="post">
            <P>The PeopleSmart Scale (Observer) can be used to give feedback about the interpersonal intelligence of someone you know. As you complete the scale, think about your direct experiences with the person you are rating as well as your observations of his/her skills with other people.</P>
            <P>Feedback is a gift. Choose wisely by being as objective as you can. It will not help the recipient if you hold back your perceptions, however positive or negative they are. You have a vantage point when observing this person that is unique.</P>
            <P>&nbsp;<INPUT NAME="for"> Name of person you are observing. </P>
            <P>&nbsp;<INPUT NAME="name"> Name of observer (your name, optional). <BR></P>
            <P>&nbsp;<INPUT NAME="sendto"> Email address to which results will be sent.<BR></P>
            
<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
      <!--
      // loop first on questions array
      for (var x = 0; x < questions.length; x++)
      {
            // write out title and evaluation criteria
            document.writeln("<h4>PeopleSmart Skill " + (x + 1) + ": " + questions[x][0] + "</h3>");
            document.writeln("<p>excellent = 4&nbsp;&nbsp;&nbsp;&nbsp;good = 3&nbsp;&nbsp;&nbsp;&nbsp;fair = 2&nbsp;&nbsp;&nbsp;poor = 1</p>");

            // now loop through options in each array within questions
            for (var y = 0; y < questions[x].length; y++)
            {
                  // write out input box and text
                  document.writeln("<input type=\"text\" name=\"value" + x + "_" + y + "\" size=\"3\" value=\"0\" onBlur=\"updateTotals(this.form," + x + ");\"> " + y + ". " + questions[x][y] + "<br>");
                  // write out hidden field for each one as well
                  document.write('<INPUT TYPE="HIDDEN" VALUE="' + questions[x][y] + '" NAME="sec_' + Number(x) + '_' + y + '">')
            }
            document.writeln("<br><input type=\"text\" name=\"subtotal" + x + "\" value=\"0\" size=\"3\" onFocus=\"this.blur();\"><b> Subtotal for Skill "+ (x + 1) + "</b><br>");
      }

      // -->
</SCRIPT><BR><INPUT VALUE="0" NAME="grandTotal"> <B>Click in Box to see this
            person's score</B> <BR><BR><INPUT TYPE="reset" VALUE="Reset">
            <INPUT ONCLICK="this.form.submit()" TYPE="button" VALUE="send the results">
            </FORM>
       <P>&nbsp;</P> </BODY>
</HTML>
0
 

Author Comment

by:jgla
ID: 6471403
Thanks for the help! It almost does everything right.

Now it doesn't give the grand total in the base form, and thus does not write the grand total to the email.

It doesn't send the results of section 8 in the email.

I hda to take line breaks out of the code above to put in my web page - I don't think I screwed anything up, but you can see it at http://www.extragravity.com/your_pq_observer.htm

Thanks again for your attention.
0
 

Author Comment

by:jgla
ID: 6477820
Can anyone help - please?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:davlun20080
ID: 6477877
i do not have time today, maybe I will have some time tomorrow... sorry.
0
 

Author Comment

by:jgla
ID: 6477924
Thanks!
0
 

Author Comment

by:jgla
ID: 6480263
I'm sorry I troubled anyone - this was a problem in the Perl that emailed the results. I had it posted in the Perl section as well, so I think it is fair to all concerned if I delete here...OK?

This problem was way over my head, and I didn't know which section to post in.

Thanks for your consideration.
0
 
LVL 3

Accepted Solution

by:
davlun20080 earned 250 total points
ID: 6480562
Members at EE worked on this a fair amount of time to answer your questions and address the problems in your page.  There were problems in your code and not just in the cgi piece and the rest we can fix as well.

Just my two cents worth....

davlun
0
 

Author Comment

by:jgla
ID: 6480676
I won't argue that people worked hard on it. It's not worth getting people worked up about, so I concede the 250 pts.

I did, however, go back to the original JS and use the Perl fix to get it working right. The answer (which was over my head, but included the code to cut and paste in) I got was "the problem was there are 47 elements in questions array and 39 in answers array.

on every q with a 0 in it we yank it out of the list and throw it in the gb (garbage)

then we back the iterator down to where it was before.
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6480978
I can code that for you if you want...I think.

As for points, not sure I deserved them all by any means, at least not until the situation is resolved completely.  If you want to pursue it in javascript let me know...

davlun

0
 

Author Comment

by:jgla
ID: 6480996
It is done...it's fixed. The change to the Perl did it.

Thanks anyway.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now