• Resolved reedy

    (@reedy)


    I have a calculated field that appears after someone types an entry into the previous field. All works fine —?however, on mobile the calculated field (which includes a sentence in this example) gets cut off.

    You can duplicate this by visiting the URL I entered into the ‘Link to the page you need help with’ field above, using a mobile device. Scroll down to the Sleep restriction calculator and type in a number, then notice that the calculated field that appears gets cut off after about four words.

    Any idea on how to fix this?

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

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

    (@codepeople)

    Hello @reedy,

    Actually, it is no issues in the behavior described. The calculated field is an input tag type=”text”, the input tags with type=”text” accept only one line, if the text is longer that the field it will bee displayed partially.

    The solution would be display the result into another control. Please, follow the steps below:

    1. Insert a “HTML Content” field with the following piece of code as its content:

    
    <div style="font-weight:500;" id="result_here"></div>
    <script>jQuery(document).on('change', '[id*="fieldname4_"]', function(){
    jQuery('#result_here').html(this.value);
    });</script>
    

    2. As the calculated field will be used now as auxiliary, tick the checkbox: “Hide Field From Public Page” in its settings.

    and that’s all.
    Best regards.

    Thread Starter reedy

    (@reedy)

    Thanks for getting back to me. This is working great as long as the user enters a number of 6 or greater. If they enter anything less than 6, nothing happens.

    This is the equation in fieldname4:

    (function(){
    if(fieldname2) jQuery('.my-field').show();
    else jQuery('.my-field').hide();
    
    return MAX(fieldname2+0.5,5.5);
    })()

    Any ideas why this is now not working for numbers less than 6?

    Plugin Author codepeople

    (@codepeople)

    Hello @reedy,

    As the current calculated field was configure as hidden, the current equation does not have much sense. Please, follow the steps below:

    1. Replace the content of the “HTML Content” field with only the tag:

    
    <div style="font-weight:500;" id="result_here"></div>
    

    2. Edit the equation as follows:

    
    (function(){
    var result = MAX(fieldname2+0.5,5.5),
    e = jQuery('#result_here');
    if(fieldname2) e.show();
    else e.hide();
    e.html(result);
    return result;
    })()
    

    or simply:

    
    (function(){
    var result = MAX(fieldname2+0.5,5.5);
    jQuery('#result_here')[(fieldname2)?'show':'hide']().html(result);
    return result;
    })()
    

    Best regards.

    Thread Starter reedy

    (@reedy)

    Thanks for the continued support.

    This works, but now the text that used to appear before and after the calculated result no longer appears.

    At the beginning of the calculated field, it should say:

    “Generally speaking, you should be spending no more than ”

    Then it shows the calculated result

    Then it should say:

    ” hours in bed.”

    So, a complete result would show something like:

    “Generally speaking, you should be spending no more than 6 hours in bed” (the bold is the calculation result).

    Is this possible?

    Plugin Author codepeople

    (@codepeople)

    Hello,

    Yes, of course that’s possible, you simply should include the text as part of the equation, as follows:

    
    (function(){
    var result = MAX(fieldname2+0.5,5.5),
    text = 'Generally speaking, you should be spending no more than '+result+' hours in bed';
    jQuery('#result_here')[(fieldname2)?'show':'hide']().html(text);
    return result;
    })()
    

    and that’s all.
    Best regards.

    Thread Starter reedy

    (@reedy)

    Working perfectly, thank you!

    Plugin Author codepeople

    (@codepeople)

    Hi,

    It has been a pleasure.

    Best regards.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Calculated Field Mobile Problem’ is closed to new replies.