HTML - Javascript loop accessing dynamic variable

Hi folks!

I have a query regarding some Javascript I am trying to get working:

image

The above code works fine, but I want it to work dynamically and use my iterator “i”. I have tried to put “i” in place of the “2”, but it doesn’t work. I’m not sure what I’m doing wrong.

Any help will be hugely appreciated :slight_smile:

Hi Paul

Did you get this working ?
I am having the same issue trying to loop a window.open. Is this not possible in Bubble ?

Hard to do / never seen such an approach. Why are you not looping through API workflows though? Any reason for this?

Hi thanks for your answer, I will try to find another workaround ??

The user case is student attendance report. The teacher collects signatures every day in a PDF report (per day per class) that is saved in the database. Admin wants to be able to select one, many reports to view, save or print.

Saving the wanted list in a state, was trying to go thru that list and have an open.window to show content.

The only other option I can think of is adding the PDF as an email attachment from the backend workflow. Which will just generate a lot of extra steps for the admin user, just to see or print records.

I just don’t understand why it as no access to the i iterator.

You have a great week !
PWB

I think you can use toolbox plugin Javascript to bubble(JTB) to solve this. Basically, output the ‘i’ to the JTB element, then you can use the value as dynamic data. So everytime you iterate, update i in the JTB’s value. Let me know if you need a screenshots vs just the concept.

You are currently referring to different variables (ZogAPI-API Call - Triangle Mock and the second item are completely different variables in your javascript function).

you should declare variables in your javascript:

let x = {bubble variable};
let y = {bubble variable2};

and then pass the variables through your javascript functions and store them as other js variables. Extract them to bubble after /w Toolbox.

Return {result of your JS function};

If you want to run a list of things through JS, you can build a recursive API workflow and run your JS script on a list of bubble items.

Thanks for the explication, I am almost there.

I found a way to run a loop in frontend with the ListShifter plugin and passing the selected data to window.open but even with “blank” it opens in the same window. But the result is good enough for now as you can navigate to all report with the back arrow.

Take care
PWB

Thank you for your input Tona, I have found a solution but will look at what you propose.

PWB