Hi,
Yes of course. Please, assign a class name to the radio buttons field, for example: myfield
Note: The class is assigned to the field through the attribute: “Add Css Layout Keywords”
Now, If you want select the choice dynamically at run time, add a new attribute to the shortcode of the form, for example, if the “id” of the form is the number 1, and there is an option in the radio buttons field whose value is for example: “xyz”, you can insert the shortcode in the page as follows:
[CP_CALCULATED_FIELDS id=”1″ myvar=”xyz”]
Finally, insert a “HTML Content” field in the form with the piece of code:
<script>
fbuilderjQuery(document).one( 'showHideDepEvent', function(){
fbuilderjQuery('.myfield input[value="'+myvar+'"]').prop('checked', true);
} );
</script>
and that’s all.
Best regards.
Thanks so much for your reply!
That is definitely working, but only for individual pages – the way I have the forms set up is on one page using tabs. The Javascript changes the value on all of the instances of the form to whichever is the last value set in the last form shortcode. Any tips?
Hi,
In this case I recommend you replace the code in the “HTML Content” field by the following one:
<script>
fbuilderjQuery(document).one( 'showHideDepEvent', function(){
fbuilderjQuery('.pbNext').on('click', function(){
var e = fbuilderjQuery('.myfield:visible input[value="' + myvar + '"]');
if (e.length && typeof myflag == 'undefined') {
e.prop('checked', true);
myflag = true;
}
});
} );
</script>
Best regards.
Just had a chance to implement this, and sadly it isn’t having any effect; any suggestions?
Hi,
Please, be sure you are using the corresponding class name in your form, and have defined correctly the variable in the shortcode.
I’ve inserted the code in my own form, and it is working fine.
If you need additional help with your project, or for checking the structure of your form, please, do not hesitate in request a custom coding service through my personal website:
http://cff.dwbooster.com/customization
Best regards.