-
A simple little script
Posted by Abel Gancsos on Nov 29, 2011 in Blog
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript">// <![CDATA[
function calculate(){
var test=document.test.cel.value;
if(test!=''){
var a=document.test.cel.value;
var temp=(((a/5)*9)+32);
document.test.far.value=temp;
}
else{
a=document.test.cel.value;
temp=(((a-32)*5)/9);;
document.test.cel.value=temp;
}
}
function reset(){
document.test.far.value="";
document.test.cel.value="";
}
</script>
JavaScript Test
<center>
</center>
<form id="test" method="post" name="test">
<table>
<tbody>
<tr>
<td align="left">Celsius:</td>
<td align="right"><input id="cel" onclick="reset()" type="text" name="celsius" /></td>
</tr>
<tr>
<td align="left">Fahrenheit :</td>
<td align="right"><input id="far" onclick="reset()" type="text" name="far" /></td>
</tr>
<tr>
<td><button onclick="calculate()" name="submit" type="button">Calculate</button></td>
</tr>
</tbody>
</table>
</form>