Dynamically assign ID

I am using nodejs and expressjs.

I load a list from a database. Selecting any of the list elements bring up an overlay with to EDIT and DELETE the selected item. I can not figure out how to send the selected list item to the express route.

What I believe needs to be done: Dynamically assign an ID to the buttons on the overlay. I tried to make a jfiddle but the overlay would not work.

Any ideas? I am sliding the overlay into view with jquery.

Thank you for taking the time to read this

I have a dynamically created list, each item with the class ".recordlongpress" and I apply this Jquery functionality to it.

    $(document).ready(function(){           
    $('.recordlongpress').bind('tap', function() {
        return;
    });
    $('.recordlongpress').bind('taphold', function() {
        $('#overlay').fadeIn('fast',function(){
            $('#box').animate({'top':'100px'},500);
        }); 

    });
    $('#boxclose').click(function(){
        $('#box').animate({'top':'-100px'},500,function(){
            $('#overlay').fadeOut('fast');
        });
    });

});

Which brings up my overlay which is done by a combination of CSS and this HTML

    <div class="overlay" id="overlay" style="display:none;"></div>
    <div class="box" id="box">  
        <a class="boxclose" id="boxclose"></a>
            <button onclick="location.href='/scape/editcustomerform/id'">Edit Contact</button>
            <button onclick="location.href='/scape/deletecustomer/ID'">Delete Contact</button>
            <button>E-mail Customer</button>
            <button>Call Customer</button>
            <button>GPS to Address</button>
            <button>Create Quote</button>
            <button>Create Sales Order</button>
            <button>Create Cash Sale</button>
        </div>
    </div>

I have tried to append the path id to the end of my route, but it just literally takes the word id. Thank you for any help

Try this:

var box     = document.getElementById('box'),
    buttons = box.getElementsByTagName('button');

for(var i = 0; i < buttons.length; i++){
    buttons[i].id = [ 'my', 'button', 'id', i ].join('-');
}

JsFiddle

Also, you may try to "map" actions:

var box     = document.getElementById('box'),
    buttons = box.getElementsByTagName('button');

var map = [
    'editcustomerform',
    'deletecustomer',
    'emailcustomer',
    'callcustomer',
    'gpstocustomer',
    'createquote',
    'createsalesorder',
    'createcashsale'
];

for(var i = 0; i < buttons.length; i++){
    buttons[i].id = [ 'my', 'button', 'id', i ].join('-');
    buttons[i].onclick = function(){ location.href = [ '/scape', map[i], 'id' ].join('/'); }
}