1. ## How to calculate?

I have tried different things to calculate numbers, including using javascripts, but can't get the result I want.

I would like to calculate (in php) this form so that what ever the user does, it will produce the number in KW (kilowats) to be stored in the database. It means that the user types in a number (like 120) and selects HP (horsepower). When the user presses the form button, I want PHP to calcultate what 120 HP is in KW's.

Here is part of the form:
<tr><td align="left" valign="top">Power/td>
<td>
<input name="kw_hp" type="text" id="kw_hp" value="<? echo \$kw_hp; ?>" maxlength="25" />&nbsp;<input type='radio' id="kw_hp_sel" value='1' name='kw_hp_sel' <?php if(\$kw_hp_sel == "1"){echo "checked";} ?> />KW&nbsp;&nbsp;<input type='radio' id="kw_hp_sel" value='2' name='kw_hp_sel' <?php if(\$kw_hp_sel == "2"){echo "checked";} ?> />HP
</td></tr>
Personally, I use http://www.onlineconversion.com/power.htm to convert.

Someone?

2. Dumb question but I'm not a scientist... what is the mathematical formula that needs to be employed (scripting and code aside)?

3. ## conversion hp <-> kw

1 hp = .746 KW

4. PHP Code:
``` \$kw = \$_POST['kw_hp'] / .746;  ```
?

5. ## conversion

I humbly submit:
I am a scientist (among other things - see my Custom User Title)
To figure out the conversion equation follow this algebraic logic:
whre "X" is the unknown value
hp times "X" = KW
(hp times "X") divided by hp = KW/hp
"X" = KW/hp
therefore
"X" = .746 / 1 or just .746
so the equation should be
hp * .746 = KW

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•