Can I populate certain fields of a form in the shortcode?

[ad_1]

Hello @zxpw

Yes, that’s possible. The plugin transforms every additional attribute in the form shortcode into javascript variables with global scope. Ex.

[CP_CALCULATED_FIELDS id="1" first_attr="123" second_attr="option A" third_attr="another value"]

The attributes’ names were chosen at random, just to describe the process.

Now, assuming the number and dropdown fields are fieldname1, fieldname2, and fieldname3, you can insert a calculated field in the form as an auxiliary (you can hide by ticking a checkbox in its settings), and enter the following equation:

(function(){
if('first_attr' in window) getField(fieldname1|n).setVal(first_attr);

if('second_attr' in window) getField(fieldname2|n).setVal(second_attr);

if('third_attr' in window) getField(fieldname3|n).setVal(third_attr);
})()

Please, note the use of the |n modifier in the equation. The plugin replaces fields’ names with their values before evaluating the equations. The |n modifier tells the plugin you are referring to the fields’ names directly instead of their values.

Best regards.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer