I feel like I'm progressing a little, I still have difficulties figuring out what to do when I'm stuck with Javascript. It's very hard but I need to get this coding done urgently.. so any help is greatly appreciated.
It's really simple, I want to make my own converter from Kelvin, Celsius and Fahrenheit. So I made these 3 variables, but I kind of realised they need their own formula, so do I need a different variable for the result? And if so where does it go? All these functions are so confusing. This is my code.
<form>
Kelvin is
<input id="kelvin" size="7" maxlength="5" type="text" placeholder="vul in" />
<p></p>
Celsius is
<input id="celsius" size="7" maxlength="9" type="text" placeholder="vul in" />
<p></p>
Fahrenheit is
<input id="fahrenheit" size="7" maxlength="9" type="text" placeholder="vul in" />
<p></p>
<input id="calculate" type="button" value="Bereken!" />
</form>
<div id="calc">Dit is kelvin
<p></p>dit is celsius
dit is fahrenheit
and then the script
<table cellSpacing=0 cellPadding=0 width=250 border=0>
document.getElementById('calculate').addEventListener('click', function() {
var kel= document.getElementById("kelvin").value;
var cel = document.getElementById("celsius").value;
var far = document.getElementById("fahrenheit").value;
var div = document.getElementById('calc');
if (( kel < 0 || cel < -273 || far < -459 || isNaN(kel) || isNaN(bev)) {
div.innerHTML = "Not valid!";
return;
}
kel = parseInt(kelvin); cel = parseInt(celsius); far = parseInt (fahrenheit);
var far = (cel * (9/5) + 35;
var kel = cel + 273;
var cel = kel - 273;
var cel = (far -32)*(5/9);
if (far = kel ) {
var text = "hello? what to do here";
}
div.innerHTML = "Het is <b>" + kelvin+ "</b> Kelvin <p></p> en het is <b>" + celcius + "</b>" en het is <b>" + fahrenheit + "</b>";
}, false);