• Resolved abragamss

    (@abragamss)


    Hello,
    I have a question here.
    I have two inputs and two outputs in the form.
    When I click the calculate button, the two outputs are displayed separately in calculated field. I need the two answers to be displayed in html text in a prescribed format.

    For ex. input1 = 2, input2 = 3
    When the calculate button is pressed,
    the output is output1 = 4, output2 = 5
    The HTML text should be “The output is 4+j5”
    If the output1 = 4, output2 = -5
    The HTML text should be “The output is 4-j5”

    Is there a way to execute this? Kindly provide the solution.

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @abragamss

    Yes, of course, that’s possible.

    As you describe, your form has two output fields. I’ll assume they are the fieldname3 and fieldname4 fields. And you want to display the result as an HTML with the structure:

    The output is fieldname3(+-)jfieldname4

    Insert an “HTML Content” field in the form with a div tag as its content where to display the output:

    <div class="output-here"></div>

    Insert a calculated fields as hidden, by ticking a checkbox in its settings, with the following piece of code as its equation:

    (function(){
    var result = CONCATENATE('The output is ', fieldname3, IF(fieldname4<0, '-', '+'), 'j', ABS(fieldname4));
    
    jQuery('.output-here').html(result);
    return result;
    })()

    Best regards.

    Thread Starter abragamss

    (@abragamss)

    Thank you so much, it is working.

    Now, in the same form, I have 2 inputs, 3 outputs and two choices.
    Let the output fields are fieldname3, fieldname4 and fieldname5.
    and the choices are choice1 = degrees and choice2 = radians.

    If I select choice1, the HTML output should be “The output is fieldname3(+-)jfieldname4”
    If I select choice2, the HTML output should be “The output is fieldname3(+-)jfieldname5”

    How to execute this? Could you help me please.

    Plugin Author codepeople

    (@codepeople)

    Hello @abragamss

    The logic is just the same, but using a conditional operation to check the ticked choice. Please, use a radio button or dropdown field for choices, but not a checkbox field because the checkbox fields allow multi-ticking choices.

    So, assuming the radio buttons field is the fieldname6, the equation would be:

    (function(){
    var result = IF(fieldname6 == 'degrees', CONCATENATE('The output is ', fieldname3, IF(fieldname4<0, '-', '+'), 'j', ABS(fieldname4)), CONCATENATE('The output is ', fieldname3, IF(fieldname4<0, '-', '+'), 'j', ABS(fieldname4)));
    
    jQuery('.output-here').html(result);
    return result;
    })()

    Best regards.

    Thread Starter abragamss

    (@abragamss)

    Thank you for the solution. Everything has worked.

    Thread Starter abragamss

    (@abragamss)

    Hi there,

    I have the equation like this.

    (function(){
    var result = CONCATENATE(‘Resistor Value = ‘, fieldname39, ‘Ohm’, fieldname35, IF(fieldname25 == ‘6 band’, fieldname37, ”));

    jQuery(‘.color-coding-output’).html(result);
    return result;
    })()`

    In this equation, ‘fieldname39’ is the output value, which ranges from ‘1 to 999000000000’.
    If the output value is 1000, it should be displayed as 1K
    If the output value is 10000, it should be displayed as 10K
    If the output value is 100000, it should be displayed as 100K
    If the output value is 1000000, it should be displayed as 1M
    If the output value is 10000000, it should be displayed as 10M
    If the output value is 100000000, it should be displayed as 100M
    If the output value is 1000000000, it should be displayed as 1G
    If the output value is 10000000000, it should be displayed as 10G.

    Is that possible to do? How to implement this?

    Plugin Author codepeople

    (@codepeople)

    Hello @abragamss

    You can define a variable as part of the equation to transform the value, and use this variable in the concatenation:

    
    (function(){
    var v = fieldname39;
    
    if(v == 1000) v = '1K';
    else if(v == 10000) v = '10K';
    else if(v == 100000) v = '100K';
    /* The other conditional statements */
    
    var result = CONCATENATE('Resistor Value = ', v, 'Ohm', fieldname35, IF(fieldname25 == '6 band', fieldname37));
    
    /* The rest of the equation's code here */
    })()
    

    I’m sorry, but the support service does not cover the implementation of the users’ projects (forms or formulas). If you need someone that implement your project, you can contact me through my private website: Click Here

    Best regards.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘How to display HTML text in prescribed format’ is closed to new replies.