I’m sorry if I’ve been vague. Its half way there though.
Basically, replacing
<h2>
with
<button onclick="bubble_fn_add_headers({output1: 'Header 1', output2: 'Child 1 of Header 1\nChild 2 of Header 1\nChild 3 of Header 1'});">Add</button>
<h2>
Does the job half way.
The main problem I’m facing here is that I have to put each H2 subheader within the output1’s value and a list of H3 subheaders within the output2’s value.
All of these subheaders are user-generated. Suppose the user added 6 sections, that would mean 6 sets of H2 subheaders followed by its H3 subheaders list. In that case, there have to be six button replacements with functions containing their unique subheader texts.
The main goal here is to get those functions their respective subheader texts by any means.
Sorry, i skimmed through your question, should have realised what you were asking for.
It’s possible to do this using native bubble operations with a bit of creativity. Alternatively you could just use javascript if you’d prefer.
Use :extract with regex on the text with the following regex pattern: (?<=\<h2>)(.*?)(?=\<\/h2>) and save the result into a text list custom state.
Then do this find and replace:
After that loop through the custom state text list and replace the placeholder texts (‘Header current iteration’) with the ‘Custom State item#current iteration’. Make sure to actually put the apostrophes otherwise the find and replace will also replace the Child X of Header Y
Are the ‘Child X of Header Y’ also user defined names? Or are they actually set to Child X of Header Y? If they are dynamic it will become a longer process, and you will have to set up the equivalent of a nested loop in bubble But it would follow a similar logic.