Convert Celsius to Fahrenheit

Discussion in 'JavaScript and AJAX' started by msn90, Jul 18, 2009.

  1. msn90

    msn90 New Member

    Joined:
    Jul 17, 2009
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    0
    Program for Convert Celsius to Fahrenheit.i think it's helpful for you.

    program code
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function convert(degree)
    {
    if (degree=="C")
     {
     F=document.getElementById("c").value * 9 / 5 + 32;
     document.getElementById("f").value=Math.round(F);
     }
    else	
     {
     C=(document.getElementById("f").value -32) * 5 / 9;
     document.getElementById("c").value=Math.round(C);
     }
    }
    </script>
    </head>
    
    <body>
    <p></p><b>Insert a number into one of the input fields below:</b></p>
    <form>
    <input id="c" name="c" onkeyup="convert('C')"> degrees Celsius<br />
    equals<br /> 
    <input id="f" name="f" onkeyup="convert('F')"> degrees Fahrenheit 
    </form>
    <p>Note that the <b>Math.round()</b> method is used, so that the result will be returned as an integer.</p>
    </body>
    
    </html>
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Looks like JavaScript. Why is it dumped in the C-C++ forum?
     
  3. hotnspicy

    hotnspicy New Member

    Joined:
    Jul 6, 2009
    Messages:
    44
    Likes Received:
    4
    Trophy Points:
    0
    Sounds interesting, but the same question for me too.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Moved to Javascript forum
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice