• Resolved chadtesting

    (@chadtesting)


    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

    (@codepeople)

    Hello @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

    Best regards.

Viewing 1 replies (of 1 total)

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