Here is a sample program that will ask the user to give weight in kilograms and then convert in pounds using JavaScript. The code is very easy to understand and use.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
Sample Program Output
Program Listing
<html>
<title> Kilograms To Pounds Converter 1.0
</title>
<body bgcolor="lightblue">
<font color="black" face="Arial" size="5">
<center>
<br>
Kilograms To Pounds Converter 1.0
<br>
</center>
</font>
<style type="text/css">
.labelText {
text-align : right;
padding-right : 3px;
color : black;
font-family:"Arial";
font-size : 18px;
}
</style>
<form name="mass" method="post">
<table>
<tr>
<tr>
<td> </td>
</tr>
<td class="labelText"> Enter Weight in Kilograms
</td>
<td> <input type="text" name="kg" size="10"/> </td>
</tr>
<tr>
<td> </td>
</tr>
</td>
<tr>
<td class="labelText">
The result is
</td>
<td>
<input type="text" name="display" size="50"/> </td>
</tr>
<tr>
<td> </td>
</tr>
</td>
<td> <input type="button" value="Compute"
title="Click here to compute the weight in pounds."
onClick="compute1()">
</td>
<td> <input type="button" value="Clear"
title="Click here to clear the text box."
onClick="clear_all()">
</td>
</table>
</font>
</form>
<script language ="javascript">
function compute1()
{
var value1, solve1,final_result;
value1 = parseInt(document.mass.kg.value);
solve1 = (value1 * 2.2);
// For two decimal places convertion
final_result = Math.round(solve1 * 100) /100;
text1=" kg = ";
text3=" kilograms multiplied by 2.2 = ";
text4=" pounds.";
result = value1 + text3 + final_result + text4;
document.mass.display.value = result;
}
function clear_all()
{
document.mass.kg.value = "";
document.mass.display.value = "";
document.mass.kg.focus();
}
</script>
</body>
</html>