I would like to start by saying that i am completely new to Ajax so please bear with me. I have to calculate the sum of all the prices sold between the two dates taken as an input.
Here is my table
Product_ID----ProductName------price------OrderDate
--- 1 -------- Chair -------- 7 ------ 2015-01-05
--- 2 -------- Lamp --------- 14 ----- 2015-01-16
--- 3 -------- Table -------- 9 ------ 2015-02-25
Here's my HTML
<html>
<head>
<script>
function showPrice(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getprice.php?q="+str,true);
xmlhttp.send();
}
}
</script>
</head>
<body>
<form>
<input type="date" name="startdate">
<p>To</p>
<input type="date" name="enddate">
<br><br>
<button type="submit" name="submit"
onclick="showAge(this.value)">Calculate</button>
</form>
<br>
<div id="txtHint"><b>Age will be listed here...</b></div>
</body>
</html>
And here is my MySQL query
SELECT SUM(price) AS TotalPrice
FROM orders
WHERE OrderDate >= '11/11/2014' AND OrderDate <= '15/11/2015'
So my question is, how can i send two dates as input using ajax to calculate the sum of prices?