Well I've managed to put the following together from various examples, however I don't believe the javascript function is even being called, below is all my code:
Javascript:
<script type="text/javascript" src="coding/jquery.js"></script>
<script type="text/javascript">
function showHint(quantity, price){
document.getElementById("txtcost").innerHTML="being called values" + quantity + price;
$.getJSON('http://website.com/ecommerce/coding/validation/calprice.php', {q: quantity, p: price}, function(data){
$('#txtcost').html('Total: ' + data.total);
$('#txtvat').html('VAT: ' + data.vat);
});
}
</script>
Display
<span id="txtcost" style="color:#060"></span>
<span id="txtvat" style="color:#060"></span>
PHP
<?php
echo "being called";
function data() {
$q = $_GET["q"];
$p =&$_GET["p"];
$total = $p * $q;
if($q >= 10)
{
$total = ($total / 10) * 9;
//echo '<strong>£ ' . $total . '</strong><span style="font-size:10px; font-weight:bold;"> Discount applied.</span>';
echo json_encode(array('total' => $total, 'vat' => '10.00'));
}
else{ echo '<strong>£ ' . $total . '<strong>'; }}
?>
Hope that helps
Note: the code isn't perfect, I want to get the initial functionality working.
EDIT:
SO far I've managed to establish:
The function is being called The correct values are being passed into the function