Loop Java Script with PHP while loop : There is a while loop to populate customer bills within which it has many buttons that triggers java script functions on click 
for each bill there many buttons with different ids Pay, Decline, Hide, confirm(Modal)

For example:

    <button form="PayBillFormForm" type="button" name="button" id ="pay" data-toggle="modal" data-target="#paymodal" class="btn btn-success" value="pay" style=" width:100%; height: 90%; ">دفع</button>

I need to number the buttons ids and also number the java script functions in order to make it works but it seems java script codes wouldn't loop

    
    $('#pay').click(function(){
    $('#action').val('pay');
});

Please advise how to fix it or suggest another method.