View Full Version : Form Conversion

01-11-2006, 01:32 AM
I'm trying to create a script that does conversions (i.e Celcius to Farenheit). I am writing it in JavaScript, but was wondering if I could do it in PHP. If so, how would I go about doing it? I am new to PHP.

ralph l mayo
01-11-2006, 01:48 AM
I'd probably do it in Javascript so the page wouldn't have to be reloaded to see the answer, but simple math is pretty much the same either way, most or all of your Javascript should transfer with nothing more than adding dollar signs to the variables.

function CtoF($C)
return $C * (9/5) + 32;
echo CtoF(100); // 212

function CtoF(C)
return C * (9/5) + 32;
document.getElementById('answer').innerHTML = CtoF(100); // 212