I have such sequence
A few divs with different names which are generated automatically

<div id="<?php echo $oneid;>">

then I have inside each this div input fields and
button with next attributes

<a id="buttonid" class="button"><span><?php echo $button; ?></span></a>

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.

<script type="text/javascript"><!--
$('#buttonid').bind('click', function() {
url: 'index.php?route=path/to/update',
type: 'post',
data: $('.active input[type=\'text\'], .active input[type=\'hidden\'], .active input[type=\'radio\']:checked, .active input[type=\'checkbox\']:checked, .active select, .active textarea') ............

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>

Any ideas?