The user will input a celsius value, then he/she will choose from a drop down list the temperature scale he/she would like to convert it to. then when the user clicks a button, the result will appear in a second text box. I've tried doing it but so far I can't even get the result to be printed in the last text box. here is my code:
<body>
<form name=myForm>
<p> Celcius Value
<input type="text" name="celcius" />
<p> Convert to
<select name="to" id="to">
<option></optio>
<option value="Farenheit"> Farenheit</option>
<option value="Kelvin"> Kelvin</option>
<option value="Rankine"> Rankine</option>
</select>
<hr size=2 color="blue">
<p> Click this to convert <button onclick="Converter()" />Convert</button>
<p> Result <input type="text" id="result" />
<script>
fucntion Converter() {
var celcius = document.myForm.celcius.value;
var sel = document.getEleemntById("to");
var selVal = sel.options[sel.selectedIndex].value;
if (selVal == "Farenheit") {
var result = (parseInt(celcius)*(9/5.0)) +32;
}else if ( selVal == "Kelvin") {
var result = parseInt(celcius)+273.15;
}else {
var result = (parseInt(celcius)+273.15)* (9/5.0);
}
document.getElementById("result").innerHTML= result;
}
</script>
</form>
</body>
Could you kind hearted people please check what's wrong with it?
You should try jslint - it can find your javascript errors: