Sorting 19 calculations to list the top 5 and then add a description based on results
Hi all,
I am pretty much at my wit's end here with JavaScript - a programmer I am not. I have 19 groups that consist of 5 questions each. The answers are ranked 1-5 and then totaled. Each group has a corresponding text description - example ( 1 - Ministering - if this is you, you are gifted with the ability to minister to others etc.). I need to find the top 5 ranked responses and then print the item number, the title and the description - example:
1. 25 - Ministering - blah blah blah
2. 24 - Hospitality - blah, blah, blah
3. 21 - Prayer - blah, blah blah
4. 19 - Healing - blah, blah, blah
5. 15 - Giving - blah, blah, blah
So this is what I have for code:
var a=this.getField("Total_g1");
event.value=(a.value*1);
var b=this.getField("Total_g2");
event.value=(b.value*1);
var c=this.getField("Total_g3");
event.value=(c.value*1);
var d=this.getField("Total_g4");
event.value=(d.value*1);
var e=this.getField("Total_g5");
event.value=(e.value*1);
var f=this.getField("Total_g6");
event.value=(f.value*1);
var g=this.getField("Total_g7");
event.value=(g.value*1);
var h=this.getField("Total_g8");
event.value=(h.value*1);
var i=this.getField("Total_g9");
event.value=(i.value*1);
var j=this.getField("Total_g10");
event.value=(j.value*1);
var k=this.getField("Total_g11");
event.value=(k.value*1);
var l=this.getField("Total_g12");
event.value=(l.value*1);
var m=this.getField("Total_g13");
event.value=(m.value*1);
var n=this.getField("Total_g14");
event.value=(n.value*1);
var o=this.getField("Total_g15");
event.value=(o.value*1);
var z=this.getField("Total_g16");
event.value=(p.value*1);
var q=this.getField("Total_g17");
event.value=(q.value*1);
var r=this.getField("Total_g18");
event.value=(r.value*1);
var s=this.getField("Total_g19");
event.value=(s.value*1);
var nums=(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,z,q,r,s);
nums.sort(function(a,b){return b-a});
event.value=(nums[0]); // This number changes in each print line
And well, this doesn't work. Any thoughts? Thanks!!
Deb
