Trying to Refresh HTML Ads From Database When Button is Clicked

I’ve uploaded numerous HTML Ads into my database and I am rendering them when a query is made by pressing a search button.

The only way I am getting them to randomize currently is when the page is refreshed.

I need to be able to have them randomize every time a button is clicked to render a new ad that is stored in the database. I was thinking a Custom State might work but I can’t figure it out and need help.

This is how I have the setup done in Bubble editor and database which currently only works properly to render randomized ads when the page is refreshed.

Any assistance or advice would be greatly appreciated.



It will only work once on page load because nothing about your search or the random number is ever changing. I would think the best solution would be to use the free plugin “Toolbox” “ListOfNumber”. This is an element that you can put on your page and you can make the start number equal 1 and the increment equal 1 and the length of list should be the search for Main Answer Ad HTML Data 300 x 250:count. Now make a custom state on your page called randomNumber that is a type number. Set it to either have a default of your choice or set the value on page load. But the most important part would be when the button is clicked you need to set the state of the randomNumber to equal the ListofNumbers:random item. Now you truly have a random number to work with that you know will only ever be as big as the list you are searching. Now in the HTML element you showed above you need to change the end to not say random item but instead use “item # randomNumber” from the custom State. Now every time the button is clicked it will display a new random item.


I appreciate the detailed explanation.

I actually use that Plugin for the Pagination on my site which I have working decently but haven’t perfected. I’ve been meaning to get back into fixing the pagination anyway so this coincides nicely working with Toolbox again.

I will try to implement this in the upcoming days as I think I understand exactly what you are saying.

Thank You for taking the time to help and hopefully I can pull this off from here but I may circle back if I get lost in the process.

Thank You,


This topic was automatically closed after 69 days. New replies are no longer allowed.