Greetings all,
I am new to InfoPath/SharePoint development, coming from Lotus Notes background. I have a performance appraisal application to redevelop in InfoPath for WIndows SharePoint Services 3.0. I will be using ShareVis to publish InfoPath forms to WSS as web browser forms.
I have 8 radio buttons, each with 4 choices (E,M,N,B). I need to calculate one Overall Rating Score from these (E,M,N, or B). The way I did it in Lotus Notes/Domino was with Javascript, using a function and swich statements, like so:
function modalscore() {
var f = document.forms[0]
var done = false;
var Ecount = 0;
var Mcount = 0;
var Ncount = 0;
var Bcount = 0;
//validate the field --------------------------------rbQ1
for (index = 0; index < doc.rbQ1.length; index++)
{
if (doc.rbQ1[index].checked)
{
done = true;
var Q1=doc.rbQ1[index].value;
}
}
if (! done)
{
alert("Please select a Rating (E,M,N, or B) for Job Factor 1.");
doc.rbQ1[0].focus();
return false; //to stop further processing
}
done = false;
(etc....)
// Calculate modal score with switch statement.
switch (Q1) {
case "E" :
Ecount += 1;
break;
case "M" :
Mcount +=1;
break;
case "N" :
Ncount += 1;
break;
case "B" :
Bcount += 1;
break;
default :
(etc.....)
and then some IF/ Else statements, like these:
if ((Ecount > Mcount) && (Ecount > Ncount) && (Ncount != ""))
{
doc.txtOverallRating.value = "M";
}
else if ((Bcount > Ecount) && (Bcount > Mcount) && (Bcount >= Ncount))
{
doc.txtOverallRating.value = "B";
}
else if ((Mcount = Bcount) && (Mcount > Ecount) && (Mcount >= Ncount))
{
doc.txtOverallRating.value = "N";
}
else if ((Ecount > Mcount) && (Ecount > Ncount) && (Ecount > Bcount))
{
doc.txtOverallRating.value = "E";
}
(etc...)
and calling the function with a 'Compute' button using:
modalscore();
I'm not sure how much (if any) code behind I'll be able to use (these will be web-enabled forms, but not using Forms Services), so I'd like to use the built-in InfoPath devices as much as possible, hopefully with Rules.
Any helpful ideas would be much appreciated! Coding solutions also welcome!
- Gary Fuller