Any suggestions?


#1

Hi everybody,

Does anyone have any suggestions too what i should add too my three way temperature converter?
Please don't give me the answer just the suggestion thanks.

Code below:

Html:

<!DOCTYPE html>

<html>
<head>
	<link href="Temprature.css" rel="stylesheet" type="text/css">

	<title>Temprature Conversion</title>
</head>

<body oninput="refreshForm()" onload="loadForm()">
	<p><input id="celsiusInputBox" oninput="enterCelsius()" type="number">&#176;C</p>


	<p>&#61;</p>


	<p><input id="fahrenheitInputBox" oninput="enterFahrenheit()" type="number">&#176;F</p>


	<p>&#61;</p>


	<p><input id="kelvinInputBox" oninput="enterKelvin()" type="number">&#176;K</p>
	<script src="script.js">
	</script>
</body>
</html>

Javascript:

function Temperature() {
	//this property get rewriten constantly as the result from all the maths that took place.
	this.kelvin = 294.15;
	
	// All the conversions
	this.setCelsius = function( celsius ) {
	    this.kelvin = celsius + 273.15;
	};
	this.setFahrenheit = function( fahrenheit ) {
		this.kelvin = ( fahrenheit + 459.67 ) * 5 / 9;
	};
	this.setKelvin = function( kelvin ) {
		this.kelvin = kelvin;
	};
	
	this.getCelsius = function() {
		return Math.round( ( this.kelvin - 273.15 ) * 10 ) / 10;
	};
	this.getFahrenheit = function() {
		return Math.round( ( this.kelvin * 9 / 5 - 459.67 ) * 10 ) / 10;
	};
	this.getKelvin = function() {
		return Math.round( this.kelvin * 10 ) / 10;
	};
	//end of final segment.
}

//resets the old values in the input boxes w/ the final results given.
function refreshForm() {
	document.getElementById( "celsiusInputBox" ).value = ourTemp.getCelsius();
	document.getElementById( "fahrenheitInputBox" ).value = ourTemp.getFahrenheit();
	document.getElementById( "kelvinInputBox" ).value = ourTemp.getKelvin();
}
//carries out the refresh form function
function loadForm() {
	refreshForm();
}

//Used too grab the values from the input boxes and also makes sure it's a number not a string.
function enterCelsius() {
	ourTemp.setCelsius( Number( document.getElementById( "celsiusInputBox" ).value ) );
}

function enterFahrenheit() {
	ourTemp.setFahrenheit( Number( document.getElementById( "fahrenheitInputBox" ).value ) );
}

function enterKelvin() {
	ourTemp.setKelvin( Number( document.getElementById( "kelvinInputBox" ).value ) );
}

//Global variable as a shortcut too the temprature object which we have created.
var ourTemp = new Temperature();

By the way everything is working.