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

    (@codepeople)

    Hello @freshrhino

    I’m sorry, but I don’t understand your question. Could you be more specific, please?

    Best regards.

    Thread Starter freshrhino

    (@freshrhino)

    Yes sorry, I have an array that created in a calculated field and I would like to be able to use items from that array in a html field. I would actually like to bring the entire array into the html field.

    Plugin Author codepeople

    (@codepeople)

    Hello @freshrhino

    The process will depend on the way you want to display this array. I’ll try to describe the process with a hypothetical example.

    Assuming you have a calculated field, with the following equation:

    (function(){
    var arr  = [fieldname1, fieldname2, fieldname3];
    })()

    The previous equation generates the arr array with the values of the fields, fieldname1, fieldname2, and fieldname3.

    Now, I’ll display this array into an “HTML Content” field with the text, The values in the array are ...

    * Insert an “HTML Content” field in the form with the tag where display the result as its content, for example:

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

    And edit the equation as follows:

    (function(){
    var arr  = [fieldname1, fieldname2, fieldname3];
    jQuery('.array-here').html(arr.join(', '));
    })()

    And that’s all.
    Best regards.

    Thread Starter freshrhino

    (@freshrhino)

    It worked except for I don’t know where you put the text “The values in the array are…”

    In your example, how could I only pull position 1 from the array? I would like to then output, “the second item in the array is… fieldname2

    Plugin Author codepeople

    (@codepeople)

    Hello @freshrhino

    I’m sorry, you can enter the text as part of the same equation:

    (function(){
    var arr  = [fieldname1, fieldname2, fieldname3];
    jQuery('.array-here').html('The values in the array are:'+arr.join(', '));
    })()

    Your current question is not about our plugin. It is a general question about javascript. In javascript the array indexes begin at zero. So, if you want to access the second item in the array, the previous equation would be:

    (function(){
    var arr  = [fieldname1, fieldname2, fieldname3];
    jQuery('.array-here').html('The second item in the array is:'+arr[1]);
    })()

    Best regards.

    Thread Starter freshrhino

    (@freshrhino)

    Ok I see, I had a syntax error using arr(1) instead of arr[1] thank you!!!

    I guess to grab an item as a value I would use .Val instead of .html?

    Thank you!!

    Plugin Author codepeople

    (@codepeople)

    Hello @freshrhino

    Excellent !!!

    Best regards.

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

The topic ‘Use field inputs in html field’ is closed to new replies.