• Resolved supersvetodiod

    (@supersvetodiod)


    Hi? need help

    (function(){
    var result = ”;
    if( AND(fieldname2, fieldname3) ){
    result = fieldname2/fieldname3;
    jQuery(‘.text-here1’).html(‘To calculate the current in a section of a circuit using Ohm’s Law, we get a value of – ‘+result+’ A‘);
    } else if( AND(fieldname2, fieldname40) ){
    result = fieldname2/fieldname40;
    jQuery(‘.text-here1’).html(‘To calculate the resistance in a section of the circuit using Ohm’s law, we get a value of – ‘+result+’ Ohms‘);
    } else if( AND(fieldname3, fieldname40) ){
    result = fieldname3*fieldname40;
    jQuery(‘.text-here1’).html(‘To calculate the voltage in a section of the circuit using Ohm’s law, we obtain a value of – ‘+result+’ V‘);
    }

    return result;

    })()

    This code is inserted into the Field Type: Calculated Field.

    This code returns the calculations and shows in Field Type: HTML content.

    My calculation fields are hidden. When inserting ROUND(),0.0001) into this code, rounding occurs only in the calculated field, which is hidden from me, and visually we see non-rounded numbers. Is there any way to fix this?

    In addition, calculations occur depending on the selection of data in the drop-down list. And when you select another variable to calculate from the drop-down list, the data is reset in the calculated field, and the HTML field is not reset, i.e. previous calculations are shown until new calculations are performed. Can this be fixed?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @supersvetodiod

    You must round the result values before include them in the HTML tags.

    (function(){
      var result = "", html = "";
      if( AND(fieldname2, fieldname3) ){
        result = ROUND(fieldname2/fieldname3, 0.0001);
        html = "To calculate the current in a section of a circuit using Ohm's Law, we get a value of – " + result + " A";
      } else if( AND(fieldname2, fieldname40) ){
        result = ROUND(fieldname2/fieldname40, 0.0001);
        html = "To calculate the resistance in a section of the circuit using Ohm's law, we get a value of – " + result + " Ohms";
      } else if( AND(fieldname3, fieldname40) ){
        result = ROUND(fieldname3*fieldname40, 0.0001);
        html = "To calculate the voltage in a section of the circuit using Ohm's law, we obtain a value of – " + result + " V";
      }
    
    
      jQuery(".text-here1").html(html);
      return result;
    })()

    Best regards.

    Thread Starter supersvetodiod

    (@supersvetodiod)

    Yes, it works, but I can’t figure out how to format the text in the form:

    Yes, it works, but I can’t figure out how to format the text in the form:

    html=”Power consumption of your circuit – <strong><font color=\”#3cce88\”>’+result+’ mW</font></strong>’/;

    I like it it is necessary for a unified website design

    Plugin Author codepeople

    (@codepeople)

    Hello @supersvetodiod

    You are using wrong the single and double quotes in the string. The correct would be:

    html='Power consumption of your circuit – <span style="font-weight:bold;color:#3cce88">'+result+' mW</span>';

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.