SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Shantra's Avatar
    Join Date
    Feb 2001
    Location
    Norway
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 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. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dumb question but I'm not a scientist... what is the mathematical formula that needs to be employed (scripting and code aside)?
    Aaron Brazell
    Technosailor



  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    conversion hp <-> kw

    1 hp = .746 KW

  4. #4
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $kw $_POST['kw_hp'] / .746
    ?
    Aaron Brazell
    Technosailor



  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    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
    Last edited by Mittineague; Aug 1, 2005 at 20:40.


Bookmarks

Posting Permissions

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