I managed to figure it out with JS. Just a minor change really. I did go back down the shortcode route as
Victor suggested but I still couldn't get it to work as I liked.I'll leave the answer here in case anyone has the same need as me in the future.So in short, I wanted to take answers from a dynamic dropdown checkbox and use those answers one at a time to fill the field name of each repeating field on the following page of a multi page form.To get the answers of the dynamic dropdown field I set the form to save drafts and used the JS and shortcode:
var names = '[frm-field-value field_id=138 user_id=current]';
var nameArr = names.split(',');
console.log(nameArr);
document.getElementById("repeaterOne").innerHTML = (nameArr[0] + "<br>"); document.getElementById("repeaterTwo").innerHTML = (nameArr[1] + "<br>");
Then I went to the customise html part of the form and gave each repeating fields <h3> tags an ID. EG ID="repeaterOne"In the after fields of the customise HTML section I used the following JS: The shortcode printed an array of "apples, bananas, pears" for example.
The JS split the array by comma and wrote it to the console. Thehe second chunk of JS found the <h3> elements by ID and injected the correct variable into it. With nameArr[0] being the first slice of the array, nameArr[1] being the second etc.
I have a multi page form. On page 1 is a dynamic field. On page two are repeater Fields.
I would like to dynamically populate the name of each repeater field with each of the selections from the dynamic field on the previous page. (Dynamic checkboxes)
Using a few methods I’ve managed to print the whole dynamic fields array into the name field of a repeater on page two, but not 1st in array for repeater one or second in array for repeater two.
I’m currently trying to achieve this using a view. The short code of which I’m placing in the name field of each repeater.
For repeater one I’m placing param=“1” within the views shortcode. In the repeaters name field. For repeater two I’m placing param=“2” within the view short code in the repeater 2’s name field.
In the view I’m using the print splice part of the code linked above within [get param=“1”] document.write(nameArr[0] + "");[get param]
When I do get it to show the single selection it breaks the rest of the form but with no error in the console. Is there a better way to do this. ?
Hope that explains it more clearly
You do realize that dynamic fields only display text values but the actual value is the entry id of the lookup record. I'm still not entirely clear why you're passing an entry id as the parameter. I may be missing something, but it sounds to me like you may be wanting to create a default value for the repeater rows, or do you really mean the field label and not the field's default value?
There are different ways to do this. You may be able to create you're own shortcode and simply apply it to the custom HTML for the repeater.
If the default value can be dynamic, then yes. I have tried that route but again it only showed an array. Rather than the first in array or second.
So in short if the user select apple, banana and grapefruit from the dynamic dropdown(checkbox), id like repeater one to have the name Apple, repeater two to have the name banana and repeater three to have the name grapefruit. But ithey would need to be able to dynamically change if the user changes their selection in the dynamic dropdown
Yes the actual name field of the field. It’s more for visual representation
Then I would look at creating a custom shortcode to display the label as you desire with each additional row in the repeater. Navigate to your form's Customize HTML page.
You want to look at the fields that come after the repeater section header. For a text field, you'll see the HTML used to generate each row. Look for the label tag? Replace the [field_name] shortcode with your own shortcode that displays the content the way you want.
If not a shortcode, you can replace the [field_name] shortcode with plain old HTML that you can change dynamically with jQuery. There are multiple approaches.
That was actually my original approach. My issue has more been splicing the js correctly to show the correct selection for each rather than an array. I’ll try again with the shortcode route rather than js.
Thanks Victor
Please login or Register to submit your answer