<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Calculate modal score (Overall Rating) from multiple option button controls</title><link>https://www.infopathdev.com:443/forums/thread/46355.aspx</link><pubDate>Thu, 27 Aug 2009 19:24:16 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:46355</guid><dc:creator>GaryFuller</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/46355.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=46355</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Okay, I figured it out myself. I used Rules in the &amp;#39;Compute&amp;#39; button to
set the field value in the Overall Rating field, first to a number
total. (I gave number values to each radio button option like so: E=4,
M=3, N=2, B=1.)&lt;br /&gt; &lt;br /&gt; If not a manager, (rbQ6, rbQ7, rbQ8 = &amp;quot;&amp;quot;),
then use the total of option buttons 1-5. The number values correspond
to predetermined letter values: 18-20=&amp;quot;E&amp;quot;, 13-17=&amp;quot;M&amp;quot;, etc. If a
manager, (rbQ6,rbQ7,rbQ8 !=&amp;quot;&amp;quot;), then use the total of option buttons
1-8. The number values correspond to different letter values:
29-32=&amp;quot;E&amp;quot;, 21-28=&amp;quot;M&amp;quot;, etc.&lt;br /&gt; &lt;br /&gt; Then I added rules that set the
letter value of the Overall Rating back from the number according to
the previous conditions. Works like a charm! Thanks to all who viewed
the query. Maybe this will help someone in the future. -GF&lt;/p&gt;</description></item><item><title>Calculate modal score (Overall Rating) from multiple option button controls</title><link>https://www.infopathdev.com:443/forums/thread/46253.aspx</link><pubDate>Wed, 26 Aug 2009 14:31:18 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:46253</guid><dc:creator>GaryFuller</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/46253.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=46253</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Greetings all,&lt;/p&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;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&amp;nbsp; a function and swich statements, like so:&lt;/p&gt;&lt;p&gt;function modalscore() {&lt;br /&gt;var f = document.forms[0]&lt;br /&gt;var done = false;&lt;br /&gt;var Ecount = 0;&lt;br /&gt;var Mcount = 0;&lt;br /&gt;var Ncount = 0;&lt;br /&gt;var Bcount = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //validate the field --------------------------------rbQ1&lt;br /&gt;for (index = 0; index &amp;lt; doc.rbQ1.length; index++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (doc.rbQ1[index].checked)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; done = true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var Q1=doc.rbQ1[index].value;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (! done)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; alert(&amp;quot;Please select a Rating (E,M,N, or B) for Job Factor 1.&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; doc.rbQ1[0].focus();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&amp;nbsp;&amp;nbsp;&amp;nbsp; //to stop further processing&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;done = false;&lt;/p&gt;&lt;p&gt;(etc....) &lt;br /&gt;&lt;/p&gt;&lt;p&gt;// Calculate modal score with switch statement.&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;switch (Q1) {&lt;br /&gt;case &amp;quot;E&amp;quot; :&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ecount += 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;case &amp;quot;M&amp;quot; :&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mcount +=1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;case &amp;quot;N&amp;quot; :&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ncount += 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;case &amp;quot;B&amp;quot; :&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Bcount += 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;default :&amp;nbsp; &lt;/p&gt;&lt;p&gt;(etc.....) &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;and then some IF/ Else statements, like these:&lt;/p&gt;&lt;p&gt;if ((Ecount &amp;gt; Mcount) &amp;amp;&amp;amp; (Ecount &amp;gt; Ncount) &amp;amp;&amp;amp; (Ncount != &amp;quot;&amp;quot;)) &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; doc.txtOverallRating.value = &amp;quot;M&amp;quot;;&lt;br /&gt;}&lt;br /&gt;else if ((Bcount &amp;gt; Ecount) &amp;amp;&amp;amp; (Bcount &amp;gt; Mcount) &amp;amp;&amp;amp; (Bcount &amp;gt;= Ncount)) &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; doc.txtOverallRating.value = &amp;quot;B&amp;quot;;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;}&lt;br /&gt;else if ((Mcount = Bcount) &amp;amp;&amp;amp; (Mcount &amp;gt; Ecount) &amp;amp;&amp;amp; (Mcount &amp;gt;= Ncount)) &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; doc.txtOverallRating.value = &amp;quot;N&amp;quot;;&lt;br /&gt;}&lt;br /&gt;else if ((Ecount &amp;gt; Mcount) &amp;amp;&amp;amp; (Ecount &amp;gt; Ncount) &amp;amp;&amp;amp; (Ecount &amp;gt; Bcount)) &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; doc.txtOverallRating.value = &amp;quot;E&amp;quot;;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;} &lt;/p&gt;&lt;p&gt;(etc...) &lt;br /&gt;&lt;/p&gt;&lt;p&gt;and calling the function with a &amp;#39;Compute&amp;#39; button using:&lt;/p&gt;&lt;p&gt;modalscore(); &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;I&amp;#39;m not sure how much (if any) code behind I&amp;#39;ll be able to use (these will be web-enabled forms, but not using Forms Services), so I&amp;#39;d like to use the built-in InfoPath devices as much as possible, hopefully with Rules.&lt;/p&gt;&lt;p&gt;Any helpful ideas would be much appreciated! Coding solutions also welcome!&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Gary Fuller &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>