Title: Help getting Loop to display properly
Last modified: February 7, 2017

---

# Help getting Loop to display properly

 *  Resolved [chadtesting](https://wordpress.org/support/users/chadtesting/)
 * (@chadtesting)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/help-getting-loop-to-display-properly/)
 * Hi there,
 * I have been working away at my understanding of Javascript, tried to give this
   forum a break, and came up with the following code. I am trying to display a 
   list of required fields in a calculated field if they aren’t chosen by one of
   my 6 dropdown fields. I think I’m on the right track but nothing is displaying.
   Could I please have a hand?
 *     ```
       (function(){
        var courses = [fieldname70,fieldname308,fieldname312,fieldname316,fieldname320,fieldname324],
            required = ['ENG4U','PSY4U','MAT4U','SCH4U'],
            msg = [],
            ret = 0,
            i;
        for(var i=0; i<courses.length; i++){
          ret |= 1 << sel[i].selectedIndex >> 1;
        }
        for(var i=0; i<required.length; i++){
         if(!(1<<i & ret)){
          msg.push(required[i]);
         }
        }
        if(msg.length == 0){
         msg = 'Everything achieved';
        } else if(msg.length == 1){
         msg = msg[0] + ' is missing';
        } else {
         msg = msg.slice(0, -1).join(', ') +' and '+ msg.pop() +' are missing';
        }
        return msg;
       jQuery('#wes_civ').html(msg);
       })()
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/help-getting-loop-to-display-properly/#post-8769833)
 * Hello [@chadtesting](https://wordpress.org/support/users/chadtesting/),
 * I’m sorry, but the support service does not cover the implementation of users’
   forms and formulas, if you need additional help I can offer you a custom coding
   service from my personal website.
 * By the way, there many basic javascript errors in your code. The code below the
   return instruction are not evaluated, the “sel” variable is not defined in the
   equation, so, it should be declared globally. I don’t understand why you are 
   trying to use bitwise operators in your equation.
 * My apologies but if your project requires complex formulas, you will need some
   basic knowledge of javascript. Mozilla Foundation has very good tutorials and
   references:
 * [https://developer.mozilla.org/en-US/docs/Web/JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
 * Best regards.

Viewing 1 replies (of 1 total)

The topic ‘Help getting Loop to display properly’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/help-getting-loop-to-display-properly/#post-8769833)
 * Status: resolved