Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-11-2006, 12:32 AM   PM User | #1
areed248
New Coder

 
Join Date: Dec 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
areed248 is an unknown quantity at this point
Form Conversion

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.
areed248 is offline   Reply With Quote
Old 01-11-2006, 12:48 AM   PM User | #2
ralph l mayo
Regular Coder

 
ralph l mayo's Avatar
 
Join Date: Nov 2005
Posts: 951
Thanks: 1
Thanked 31 Times in 29 Posts
ralph l mayo is on a distinguished road
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.

PHP Code:
function CtoF($C)
{
    return 
$C * (9/5) + 32;
}
echo 
CtoF(100); // 212 
Code:
function CtoF(C)
{
    return C * (9/5) + 32;
}
document.getElementById('answer').innerHTML = CtoF(100); // 212
ralph l mayo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:28 AM.


Advertisement
Log in to turn off these ads.