Thursday, 10 September 2015

SIMPLE PERCENTAGE TO DECIMAL CALCULATOR CODE




-----------------------------------------------------------------------------------------------------------------
COPY AND PASTE BELOW CODE IN POST HTML SECTION
------------------------------------------------------------------------------------------------------------------
EXP:1
---------------------------------------------------------------------------------------------------------------------
<html>
<head>
<title>SIMPLE PERCENTAGE TO DECIMAL CALCULATOR</title>
</head>
<body>
<h1 align="center"> SIMPLE PERCENTAGE TO DECIMAL CALCULATOR</h1>
<form action="javascript:calc()">
Input: <input type="text" id="input"/><br />
Percent: <input type="text" id="percent" value="100"/>%<br />
Output: <input type="text" id="output"/><br />
<input type="submit" />
</form>

<script>
function calc() {
var i = document.getElementById("input").value;
var p = document.getElementById("percent").value;
var o = (i/100) ;
document.getElementById("output").value = o;
}
</script>

</body>

</html>

------------------------------------------------------------------------------------------------------------------
EXP:2
---------------------------------------------------------------------------------------------------------------------

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>

<script type='text/javascript' src='//code.jquery.com/jquery-1.8.3.js'></script>

<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type='text/css'>
span{width:50px; display:inline-block}
input{margin-right:3px;}
</style>

<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(document).ready(function(){
$("‪#‎price1‬‪#‎price2‬").keyup(function() {
var priceOne = parseFloat($("#price1").val());
var priceTwo = parseFloat($("#price2").val());
var rate = parseFloat($("‪#‎rate‬").val());
if ($("#price1").val() && $("#price2").val()){
$('#rate').val(((priceTwo - priceOne) / priceOne * 100).toFixed(2));
}
});
$("#rate").keyup(function() {
var priceOne = parseFloat($("#price1").val());
var rate = parseFloat($("#rate").val());
if ($("#rate").val() && $("#price1").val() && $("#price2").val()){
$('#price2').val(((priceOne * rate)/ 100 + priceOne).toFixed(2));
}
});
})
});//]]>
</script>
</head>
<body>
<div>
<span>Price1</span><input id="price1" type="text"/>
</div>
<br>
<div>
<span>Price2</span><input id="price2" type="text"/></div>
<br>
<div><span>Rate</span><input id="rate" type="text" style="width:50px"/>%</div>
<p>Write down two numbers, then change the Rate number</p>
</body>
</html>







0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

FB Gadgets | Template Designed by Fatakat PhotosCoolBThemes.com
Code by : paid web directory

https://www.google.co.uk/search?q=site%3Ablogspot.com+fbgadgets