I'm trying to take a value that a php page outputs and use it later as a variable in a calculation. Currently I am trying this:
var price = function() {
$.get('gox.php')
}
function toDol(elem) {
var btcToDol = parseFloat(elem.value) * price || '';
document.getElementById('dol').value = btcToDol.toFixed(2);
}
function toBtc(elem) {
var dolToBtc = parseFloat(elem.value) / price || '';
document.getElementById('btc').value = dolToBtc.toFixed(4);
}
The important part is I want the 'price' variable to equal the value gox.php outputs (e.g. 99.9999) so that I can use it later to do the math in functions 'toDol' and 'toBtc'.
Thank you for your help!