Never used ajax before
I have a drop down select list with 3 hard coded options.
Once one is selected i want it to update the database
function updateStatus(status, id){PHP Code:<select name="status" id="id" onchange="updateStatus(this.value,<?php echo $row['id']; ?>)">
<option value="<?php echo $row['status']; ?>"><?php echo $row['status']; ?></option>
<option value="Order Placed">Order Placed</option>
<option value="Processing">Processing</option>
<option value="Dispatched">Dispatched</option>
</select>
var url = "updatestatus.html";
function DoCallback(data){
if (window.XMLHttpRequest) { // branch for native XMLHttpRequest object
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open('POST', url, true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(data);
} else if (window.ActiveXObject) { // branch for IE/Windows ActiveX version
req = new ActiveXObject('Microsoft.XMLHTTP')
if (req) {
req.onreadystatechange = processReqChange;
req.open('POST', url, true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(data);
}
}
}
}



Reply With Quote

Bookmarks