WordPress.org

Ready to get started?Download WordPress

Forums

Calculated Fields Form
[resolved] Copying a Calculated Field's value (6 posts)

  1. McTwist
    Member
    Posted 6 months ago #

    I was wondering how I could access the value of a Calculated Field via CSS or jQuery, since the output is not located in the <input value=" ">.

    Or better yet, is there a way to have a placeholder or "token" of this value to be pasted into a Predefined Value field?

    Thanks!

    https://wordpress.org/plugins/calculated-fields-form/

  2. codepeople
    Member
    Plugin Author

    Posted 6 months ago #

    Hi,

    Through the attribute "Add Css Layout Keywords", available for all field in the form, it is possible assign a classname to the field.

    For example if you assign the classname "my-class" to the field, you can get it with the jQuery expression: jQuery(".my-class"), and its value with: jQuery(".my-class").val()

    Best regards.

  3. McTwist
    Member
    Posted 6 months ago #

    Thanks for the fast response!

    No such luck. This is what I'm seeing:

    <input id="fieldname1_1" name="fieldname1_1" readonly="" class="codepeoplecalculatedfield field small" type="text" value="" dep="" notdep="">

    I can access this with jQuery without having to apply a class to the surrounding field div. It's the value="" that I'm talking about. It's empty because the value is not actually being placed in there. The script below the calculated field - this:

    fbuilderjQuery.fbuilder.calculator.addEquation("fieldname1_1", "prec( (fieldname3_1+fieldname4_1+fieldname5_1) ,2)", {"suffix":"","prefix":"$","groupingsymbol":"","decimalsymbol":"."}, [], "_1");

    does the math but does not apply it to the input's value.

  4. codepeople
    Member
    Plugin Author

    Posted 6 months ago #

    Hi,

    The equation associated to the calculated field is evaluated dynamically when change the value of any fields that are part of the equation. I'm sorry, but I don't understand exactly what do you need.

    Best regards.

  5. McTwist
    Member
    Posted 6 months ago #

    I need to know how to capture the equation's output. I know the number is dynamic, but it still exists. You can select it when using the form, but the way the script is built, the number is placed over the input box instead of setting the value of the <input> within the dfield div.

    <div class="dfield">
    <input id="fieldname1_1" name="fieldname1_1" readonly="" class="codepeoplecalculatedfield field small valid" type="text" value="" dep="" notdep=""><span class="uh"></span>
    </div>

    I would like to set the input form element's value to the equation's result via jQuery or Javascript.

  6. codepeople
    Member
    Plugin Author

    Posted 6 months ago #

    Hi,

    The equation is not assigned directly to the calculated field, the equation is generated through the <script></script> tags, when the calculated field is displayed in the form. If you want make the calculus by yourself, don't use calcualted fields, and implement your own codes, for example, using numeric fields, or any other type of fields available. But your code is not part of plugin.

    Best regards.

Reply

You must log in to post.

About this Plugin

About this Topic