• Resolved saralanda

    (@saralanda)


    Hello,

    I am using a text area field and want to store the information including line breaks in a calculated field for further use.

    Thanks,

    Sara

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author CodePeople2

    (@codepeople2)

    Hello @saralanda

    Thank you very much for using our plugin.

    The plugin preprocesses the fields’ values to use them in mathematical operations in the equations. However, it allows you to get the raw field’s value without preprocessing by using the |r modifier with the field’s name.

    For example, if you use fieldname123 in the equation, it will be the preprocessed field’s value and fieldname123|r its raw value (with the line breaks).

    Note that the calculated fields utilize <input> tags. Input tags are single-line controls, which do not support line breaks or render HTML. So, you cannot visualize the text area content with the line breaks directly in the calculated field.

    How do you want to use text area value?

    Best regards.

    Thread Starter saralanda

    (@saralanda)

    I am creating a url whose parameters are defined by user input. One of these parameters is defined by whatever is written in the textarea field. I want to identify the line breaks, then replace them with something that is url-friendly (XXX), then add that to my url as a parameter.

    For example:

    Textarea1 input: This is an example <br>Of what I would like to get<br>And store

    Calculation to replace <br> with XXX

    Calculated field1: myurl.com/?textarea=This is an example XXX Of what I would like to get XXX And store

    Plugin Author CodePeople2

    (@codepeople2)

    Hello @saralanda

    In textareas the line breaks are not <br> tags, they are \n characters.

    So, assuming the fieldname1 is a textarea field, and you want to replace the line breaks with xxx, the correct code in the equation would be:

    fieldname1|r.replace(/[\n\r]/g, 'xxx');

    However, you don’t need to generate the URL yourself by using the plugin operations. You can use the generateURL operation in the “URL Operations” module:

    https://cff.dwbooster.com/documentation#url-module

    For example, assuming you want to generate the URL https://www.yourwebsite.com/?param1=<the value of the textarea field>

    In this hypothetical case the calculated field equation would be:

    generateURL('https://www.yourwebsite.com', {param1:fieldname1|r});

    Best regards.

    Thread Starter saralanda

    (@saralanda)

    Thank you! This works really well.

    One last question. When I use the getURLParameter(param1) in another calculator to get the parameter with line breaks, it ignores them. I tried the following :
    (function(){
    var result = ”;
    result = getURLParameter(‘param1’, ”);
    result = result.replace(/%0A/g, ‘<br>’);
    jQuery(‘.notes’).html(result);
    return result;
    })();

    Plugin Author CodePeople2

    (@codepeople2)

    Hello @saralanda

    %0A is the URL encoded character, when you call getURLParameter its result is the original one. So, the line of code would be:

    result = result.replace(/\\n/g, '<br>');

    Best regards.

    Thread Starter saralanda

    (@saralanda)

    Thank you so much for your quick response. Unfortunately, the code is still ignoring the line breaks. This is what I have:


    (function(){
    var result = ”;
    result = getURLParameter(‘param1’, ”);

    result = result.replace(/\\n/g, ‘<br>’);
    jQuery(‘.notes’).html(result);
    return result;
    })();

    Where param1 = This%0Ais%0Aexample

    • This reply was modified 3 weeks, 2 days ago by saralanda.
    Plugin Author CodePeople2

    (@codepeople2)

    Hello @saralanda

    Please provide the link to the page containing the form to check your code in action.

    Best regards.

    Thread Starter saralanda

    (@saralanda)

    https://tulumcharters.com/test1?wpf24098_76=This%0Ais%0Aexample

    • This reply was modified 3 weeks, 2 days ago by saralanda.
    Plugin Author CodePeople2

    (@codepeople2)

    Hello @saralanda

    My apologies, but we have detected that you are using a commercial version of our plugin. Unfortunately, the forum policy does not allow us to support customers.

    We suggest contacting our dedicated support team for assistance with your questions.

    Commercial products are not supported in these forums. We will happily answer this and any other questions you can have on our own site.

    Thank you.

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