- Joined
- Dec 4, 2007
- Messages
- 1,936
- Reaction score
- 96
Code:
<?php
$pricequery = mysql_query("SELECT * FROM `prices`");
$row = mysql_fetch_row($pricequery);
$one = $row['0'];
$five = $row['5'];
$twenty = $row['20'];
$onehundred = $row['100'];
?>
<script type="text/javascript">
$('input#GoldQuantity').keyup(function() {
var goldQuantity = $('input#GoldQuantity').val();
if (parseInt(goldQuantity) != goldQuantity) {
$('#Update').html('Input Error');
} else {
var multiplier = -1; // If something goes wrong, then the user will notice that their total is oddly negative.
if (goldQuantity >= 251) {
multiplier = 99999; //Orders over 250M
} else if (goldQuantity >= 100) {
multiplier = <?php $onehundred ?>; //Orders over 100M
} else if (goldQuantity >= 20) {
multiplier = <?php $twenty ?>; //Orders over 20M
} else if (goldQuantity >= 5) {
multiplier = <?php $five ?>; //Orders over 5M
} else if (goldQuantity >= 0) {
multiplier = <?php $one ?>; //Orders over 1M
}
var algorithm = goldQuantity * multiplier;
$('#Update').html('$' + algorithm);
}
});
</script>
I've been trying to get these PHP variables to work in Javascript, but they won't. Are you unable to do this for some reason?
It worked fine before, but now with the variables there is just doesn't update (when the value in one box is edited by the user, this one is supposed to change based on that - live in the browser).