MyTechSupport.ca :: Your Computer Technical Resource Headquarters! MyTechSupport.ca :: Your Computer Technical Resource Headquarters!
HOME FORUMS RESOURCES & TOOLS ARTICLES ONLINE STORE ABOUT US
Computer Support Forums arrow Software Support arrow Programming Problems arrow Topic: JavaScript function library
August 25, 2019, 03:51:05 PM
 

Home Forum Rules Help Search Mobile Version Login Register

Welcome, Guest. Please login or register.
Did you miss your activation email?
August 25, 2019, 03:51:05 PM

Login with username, password and session length
 
News
New  New Poll on our main page!
"My experience with Vista..."
  0 Members and 1 Guest are viewing this topic.
Pages: [1] Go Down Print
Author Topic: JavaScript function library  (Read 2084 times)
watson6
Jr. Member
**

Karma: +0/-0
Offline Offline

Gender: Male
Posts: 12


Bookmark and Share

View Profile
« on: July 04, 2005, 08:24:26 PM »

Hi, I am trying help my wife with her college work and being new to JavaScript i am running into problems.

The program im trying to sort is one that converts fahreinheit to celsius. It calls upon a function library called conversion_library.

This is the program so far:(function library is further down)

<html>
<head>
<title>Convert from Fahrenheit to Celsius</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script
   language="JavaScript"
   src="number_library.js"
   type="text/javascript">
</script>

<script src = "conversion_library.js> </script>
<script
   language="JavaScript"
   type="text/javascript">
   
   //
   // A FUNCTION THAT TAKES AN INPUT VALUE AND CONVERTS IT TO CELSIUS AFTER
   // TESTING IF THE INPUT IS NUMERIC. THIS FUNCTION USES THE PRE-DEFINED
   // LIBRARIES number_library.js AND conversion_library.js IF THE INPUT IS
   // NOT NUMERIC AN ERROR MESSAGE IS SHOWN.
   //
   function convertToCelsius (inputValue) {
   
      var inputIsNotNumeric = false; // BOOLEAN VALUE - IS THE INPUT A NON-NUMERIC

VALUE - INITIALISED TO FALSE
      var aResult = 0.0; // THE OUTPUT VALUE - INITIALISED TO 0.0
      
      //
      // TEST THE INPUT VALUE TO SEE IF IT IS NON-NUMERIC OR NOT
      //
      inputIsNotNumeric = isNotNumeric (inputValue);
      
      //
      // IF THE INPUT IS NUMERIC - PROCEED WITH CONVERSION TO CELSIUS
      // AND DISPLAYING THE OUTPUT OTHERWISE PRODUCE AN ERROR MESSAGE
      //
      if (inputIsNotNumeric == false) {
      
         aResult = roundToTwoPlaces (aResult);
         window.alert("The temperature to two decimal places is " + aResult + '

degrees Celsius.');
      } else {
      
         window.alert("Your input was not a number.");
      }
   }
</script>
</head>

<body>
<p><strong>A JavaScript program for converting from Fahrenheit to Celsius</strong></p>
<form
   name="conversionForm"
   method="post"
   action="">
  The Fahrenheit Temperature
  <input
     type="text"
   name="theNumber">
  <br>
  <input
     name="submitButton"
   type="submit"
   id="submitButton"
   value="Convert to Celsius"
   onClick="convertToCelsius (document.conversionForm.theNumber.value);">
  <input
     name="clearButton"
   type="reset"
   id="clearButton"
   value="Clear Form">
</form>
</body>
</html>



conversion_library:

A FUNCTION TO CONVERT A FAHRENHEIT TEMPERATURE
// INTO A CELSIUS TEMPERATURE. IT RECEIVES A SINGLE
// INPUT (fahrenheitTemp) AND RETURNS A SINGLE VALUE
// (celsiusTemp)
//
function fahrenheitToCelsius (fahrenheitTemp) {

   var celsiusTemp = 0;
   
   celsiusTemp = (fahrenheitTemp - 32) * (5 / 9);
   
   return celsiusTemp;
}

//
// A FUNCTION TO CONVERT A CELSIUS TEMPERATURE
// INTO A FAHRENHEIT TEMPERATURE. IT RECEIVES A SINGLE
// INPUT (celsiusTemp) AND RETURNS A SINGLE VALUE
// (fahrenheitTemp)
//
function celsiusToFahrenheit (celsiusTemp) {

}

function celsiusToKelvin (celsiusTemp) {

   var kelvinTemp = 0;
   
   kelvinTemp = celsiusTemp + 273.15;
   
   return kelvinTemp;
}

function kelvinToCelsius (kelvinTemp) {

}

Logged

 
Pages: [1] Go Up Print 
 
Jump to:  

Powered by MySQL Powered by PHP

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS!

Disclaimer
This site is NOT responsible for any damage that the information on this site may cause to your system. Everything you try, whether inspired by the response given from this site or not, is entirely at your own risk. All product names and company names used herein are for identification purpose only and may be trademarks or registered trademarks of their respective owners. We are in no way affiliated or representing any of the companies on this site unless specified.
Back to Top
Stop Spam Harvesters, Join Project Honey Pot Fight Back Against Spammers! Get Firefox! Get Thunderbird! View Sylvain Amyots profile on LinkedIn
Back to Top
Google visited last this page November 09, 2018, 03:31:29 AM