And below I have javascript which is applying only to one certain div class with name active so I have to make div with any id work when button was pressed.
This is the question how to make work this script after user press any $button?
When on page is only one div it works fine.
Next way doesnt work
<a onclick=“document.getElementById(‘<?php echo $oneid;?>’).setAttribute(‘class’, ‘active’);” id=“buttonid” class=“button”><span><?php echo $button; ?></span></a>
Your javascript (which is JQuery, by the way) applies to an ID of “buttonid”.
A page can only have one instance of a CSS ID (an ID must be unique).
That answers your question.
If you want to apply this to all buttons, I suggest you define them with the same unique CSS class and modify your JQuery to ‘bind’ to that class. In that case, avoid applying a CSS ID to the button(s) in your PHP output because you will have the same ID duplicated on the page.