Monday, May 13, 2019

Simple JavaScript Currency Converter | Currency Converter using JavaScript

In this tutorial, we will create a Simple Currency Converter using Javascript. I'm trying to make a currency converter that converts between several different currencies on change. It uses some pre-determined exchange rates. JavaScript is a scripting or programming language that allows you to implement complex things on web pages. In this program, you will learn how Currency Converter using JavaScript. So, let start the Simple JavaScript Currency Converter.



Currency Converter using JavaScript
Currency Converter using JavaScript





JavaScript Currency Input:

<html>
<head>

<!-- *****************start css part***************** -->
<style>
body
{
width:400px;

border:1px solid white;

position:absolute;

top:150px;
left:100px;
background-color:black;
color:white;
}

</style>
<!-- *****************end css part***************** -->



<!-- *****************start javascript part***************** -->
<script>
function check(){
var a,b,c,result;
b=Number(document.getElementById("selec").value);
c=Number(document.getElementById("selec2").value);
a=Number(document.getElementById("a").value);
if(b==c)
{
alert("You have entered Two Same country: Please try again!!!");
}
else
{
switch (b)
{

<!-- *****************start case 1***************** -->
case 1:
{
if(b==1 && c==2)
{
result=83.70*a;
}
else if(b==1 && c==2)
{
result=64.94*a;
}
else if(b==1 && c==3)
{
result=112.11*a;
}
else if(b==1 && c==4)
{
result=0.85*a;
}
else if(b==1 && c==5)
{
result=0.85*a;
}
break;
}
<!-- *****************end case 1***************** -->



<!-- *****************start case 2***************** -->
case 2:
{
if(b==2 && c==1)
{
result=0.01*a;
}
else if(b==2 && c==3)
{
result=0.78*a;
}
else if(b==2 && c==4)
{
result=1.34*a;
}
else if(b==2 && c==5)
{
result=0.01*a;
}
break;
}
<!-- *****************end case 2***************** -->



<!-- *****************start case 3***************** -->
case 3:
{
if(b==3 && c==1)
{
result=0.02*a;
}
else if(b==3 && c==2)
{
result=1.29*a;
}
else if(b==3 && c==4)
{
result=1.73*a;
}
else if(b==3 && c==5)
{
result=0.01*a;
}
break;
}
<!-- *****************end case 3***************** -->



<!-- *****************start case 4***************** -->
case 4:
{
if(b==4 && c==1)
{
result=0.01*a;
}
else if(b==4 && c==2)
{
result=0.75*a;
}
else if(b==4 && c==3)
{
result=0.58*a;
}
else if(b==4 && c==5)
{
result=0.01*a;
}
break;
}
<!-- *****************end case 4***************** -->



<!-- *****************start case 5***************** -->
case 5:
{
if(b==5 && c==1)
{
result=1.18*a;
}
else if(b==5 && c==2)
{
result=98.69*a;
}
else if(b==5 && c==3)
{
result=76.57*a;
}
else if(b==5 && c==4)
{
result=132.20*a;
}
break;
}
<!-- *****************end case 5***************** -->


}
}
document.getElementById("answer").value=result;
}
</script>
<!-- *****************end javascript part***************** -->




</head>
<body>
<center>
Enter Your Currency Amount:<br>
<input type="number" id="a" placeholder="00.00">
<br><br>
Select Your Currency Country:<br><select id="selec">
<option value="0">-------</option>
<option value="1">America</option>
<option value="2">Bangadesh</option>
<option value="3">India</option>
<option value="4">Japan</option>
<option value="5">Franch</option>
</select><br><br>
Chose The Converter Country:<br><select id="selec2">
<option value="0">-------</option>
<option value="1">America</option>
<option value="2">Bangadesh</option>
<option value="3">India</option>
<option value="4">Japan</option>
<option value="5">Franch</option></select><br><br>
          <input type="button" onclick="check()" value="Convert"></button>
  <br>The Converted Amount is:<br>
<input type="number" id="answer" placeholder="00.00">
</center>
</body>
</html>



Currency Converter Output:


Simple JavaScript Currency Converter
Simple JavaScript Currency Converter 




Simple JavaScript Currency Converter
Simple JavaScript Currency Converter 



0 comments:

Post a Comment