Q:

Help 3 buttons in AJAX

I want to add 3 buttons with different actions. I have made the PHP code that handles those actions but in order to get to those actions I need with ajax and method GET to add 2 parameters: id and act. I made this, in a very primitive way! It does not work because it only gets the first id="act" (which in this case is delete) no matter what I click!:
<form>
     <input type="hidden" id="act" value="delete">
     <input type="hidden"  id="id" value="'.$row['order_id'].'">    
     <input type="button" id="delete" value="delete" onclick="ajaxFunction()">
</form>

<form>
    <input type="hidden" id="act" value="edit">
    <input type="hidden" id="id" value="'.$row['order_id'].'">
    <input type="button" id="edit" value="edit" onclick="ajaxFunction()">
</form>

And here is the AJAX function:
<script language="javascript" type="text/javascript">
<!-- 
//Browser Support Code
function ajaxFunction(){
    var ajaxRequest;  // The variable that makes Ajax possible!

    try{
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        // Internet Explorer Browsers
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                // Something went wrong
                alert("Your browser broke!");
                return false;
            }
        }
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4){
            document.myForm.time.value = ajaxRequest.responseText;
        }
    }
    var id = document.getElementById(\'id\').value;
    var act = document.getElementById(\'act\').value;
    var queryString = "?id=" + id + "&act=" + act;
    ajaxRequest.open("GET", "classes/ajaxed/reservation_functions.php" + queryString, true);
    ajaxRequest.send(null); 
}

//-->
</script>

So my question is how to make those 3 buttons with delete, edit, print and each one to send with it GET method the proper ID and ACTION (id & act)?

A:

Simplified Markup:
<button onclick="ajaxFunction('delete', '<?php echo $row['order_id']; ?>')">Delete</button>
<button onclick="ajaxFunction('edit', '<?php echo $row['order_id']; ?>')">Edit</button>
<button onclick="ajaxFunction('print', '<?php echo $row['order_id']; ?>')">Print</button>

Change you need to make to your JS function:
function ajaxFunction(action,id){
    ...
    var queryString = "?id=" + id + "&act=" + action;
    ...
}

