Javascript Question about converting Celcius to Fahrenheit

Ads
 

Javascript Question about converting Celcius to Fahrenheit

How to create a program to ask the user to enter a temperature in degrees celcius

it convert it to fahrenheit using the following formula: f = (c*9/5)+32;

It then displays the following table


|Celcius: | 30 |
|Fahrenheit | 56? |
I really have difficulties with it. Can you help me.

Do I have to put var celsius and Fahrenheit after opening javascript? Do I have to prompt both of them. I try and try and I don't know how to put this code right? I am student of Webmaster 2 and need to get this one till next thursday. Can you reply

View Answers

May 27, 2013 at 7:54 PM

hi friend,

Try the following code, may this will be helpful for you

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Celcius To Farenheit</title>
<script type="text/javascript">
//function temp (form) {
    function cToF(){    
    var c = document.getElementById("cl").value;    
    var f = c*(9/5)+32;
    //var v = document.getElementById("fa").value = f;
    addTable(f);

  //form.fahrenheit.value = form.celsius.value*(9/5)+32;
}
    function addTable(tdValue) {        

        var table = document.getElementById("table1");

        var rowCount = table.rows.length;
        if(rowCount < 1)
        {      
        var row = table.insertRow(rowCount);       
        alert("Number of Rows " +rowCount);

        var cell1 = row.insertCell(0);        
        var element1 = document.createTextNode("Fahrenheit");        
        cell1.appendChild(element1);

        var cell2 = row.insertCell(1);
        var element2 = document.createTextNode(tdValue);        
        cell2.appendChild(element2);        
        }       
        }
</script>
</head>
<body>
<form>
<div align="center">
<center><p><b>Input Celsius In Degree </b><input type="text" size="15" id="cl"></p></center>
<!--<center><p><b>Degrees In Fahrenheit <input type="text" size="15" id="fa"></b></p></center>-->
<center><p><input type="button" value=" Get Fahrenheit " onclick="cToF();"/></p></center>
</div>
<div id="ctof">
<table align="center" id="table1" border="1">
</table>
</div>
</form>
</body>
</html>

Thanks.

Ads









Related Tutorials/Questions & Answers:
Javascript Question about converting Celcius to Fahrenheit
Javascript Question about converting Celcius to Fahrenheit  How...; It then displays the following table |Celcius: | 30 | |Fahrenheit | 56... to put var celsius and Fahrenheit after opening javascript? Do I have to prompt
Question about a flex...
Question about a flex...  Is there good Future for Adobe flex
Advertisements
question about applet
question about applet  how to run java applet on wed browser   Hi Friend, Please visit the following link: Applet Tutorials Thanks
question about database
question about database  sir i have made a drop down button using html..now i want to retrieve values from database so that they my appear in my drop down button..how can i do this....i have taken many fields such as type,ward id
question about mixing two strings
question about mixing two strings  using java script we need to ask two strig and combine them like.. str1= helo str2= worl combined string= hweolrol
temperature converting
converted Celcius to Fahrenheit and vice versa. For this, we have create three functions celcius(), fahrenheit() and display table which display the conveted...))); } System.out.println("Fahrenheit (F) Celcius (C) "); for(int i=32;i<=212;i+=10
Question about "Insert text file data into Database"
Question about "Insert text file data into Database"  Hey I was reading the tutorial "Insert text file data into Database", (awesome btw), and noticed that both a FileInputStream, a DataInputStream and a BufferedReader
ModuleNotFoundError: No module named 'celcius'
ModuleNotFoundError: No module named 'celcius'  Hi, My Python... 'celcius' How to remove the ModuleNotFoundError: No module named 'celcius... to install padas library. You can install celcius python with following command
ModuleNotFoundError: No module named 'celcius'
ModuleNotFoundError: No module named 'celcius'  Hi, My Python... 'celcius' How to remove the ModuleNotFoundError: No module named 'celcius... to install padas library. You can install celcius python with following command
Question about parsing XML document with DOM in JAVA.
Question about parsing XML document with DOM in JAVA.  Hi, I need to parse a XML file witch has info about classes. So i have for each class to have its methods and for each method to get its parameters. I'm trying to do
please help me to solve this question about array
please help me to solve this question about array  write a program thatt stores vowels (a,e,i,o and u)in an array. Ask the user to enter any character. The program should ignore the case of that character (uppercase or lowercase
Urgent query about CreateTextFile using Javascript
Urgent query about CreateTextFile using Javascript  Dear All, I am creating a file using the code below which create a text file, but I don't want any body to access the same, either it should be password protected or it should
ModuleNotFoundError: No module named 'django-fahrenheit'
ModuleNotFoundError: No module named 'django-fahrenheit'  Hi, My... named 'django-fahrenheit' How to remove the ModuleNotFoundError: No module named 'django-fahrenheit' error? Thanks   Hi, In your
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1) Write a full program for the bubble sort algorithm. User is required to enter specific input numbers and the program will be able to sort the given numbers
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1) Write a full program for the bubble sort algorithm. User is required to enter specific input numbers and the program will be able to sort the given numbers
javascript
javascript  write a program to display implement about browsers using javascript
Converting ISO8601-compliant String to java.util.Date
Converting ISO8601-compliant String to java.util.Date  Converting ISO8601-compliant String to java.util.Date
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
Question
Question   When there is an exception in my program how java runtime system handles
Converting NSURL to NSString creating a problem
Converting NSURL to NSString creating a problem  Hi , In my iPad/iPhone universal application, we are trying to covert theNSURL to NSString which cause the application crash. Does any one have idea about converting NSURL
Converting NSURL to NSString creating a problem
Converting NSURL to NSString creating a problem  Hi , In my iPad/iPhone universal application, we are trying to covert theNSURL to NSString which cause the application crash. Does any one have idea about converting NSURL
question
question  dear sir/madam my question is how to compare two text format in java..we are java beginners..so we need the complete source code for above mentioned question...we have to compare each and every word
question
question  i used the following code to disable browser back page javascript:window.history.forward(1); but not worked .please give the correct code to disable back page using jsp or javascript
question
question  i need a simple javascript or jsp code to send message from one mail to another mail
question
question  i need a simple javascript or jsp code to send message from one mail to another mail
question
question  how to display the uploaded video file size in database using java or javascript
Question?
Question?  My question is how to: Add a menu bar to the program with a File menu. In the File menu, add a submenu (JMenuItem) called About. When the user clicks on the About menu item, display a JOptionPane message dialog
Converting XML to string
Converting XML to string  Hi Friends, I had an requirement in which a java program receives an xml messages from external web application... some one suggest how can I go about it or could some one provide me with sample
JavaScript
JavaScript  clone JavaScript
question
question  Dear sir i had some typing mistake at previous question so its my humble request to let me know the steps to start the tomcat6 under the tomcat directory

Ads