Location: PHPKode > scripts > Free PHP Ajax Currency Rate Exchanger Calculator > free-php-ajax-currency-rate-exchanger-calculator/index.php
<?php
/*
This script was downloaded at:
LightPHPScripts.com
Please support us by visiting
out website and letting people
know of it.
Produced under: LGPL
*/

// Include Class
include_once('currencyClass.php');

// Get list of currencies
$c = new JOJO_Currency_yahoo();
$list = $c->getCurrencies();

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Ajax Currency Exchange Rate Calculator</title>
<script language="javascript">

// Get HTTP Request
var http;
if (!http && typeof XMLHttpRequest != 'undefined') {
	try {
		http = new XMLHttpRequest();
	} catch (e) {
		http = false;
	}
}
	
// Actual Ajax call
function doAjax()
{
	var N = document.getElementById('N').value;
	var F = document.getElementById('F').value;
	var T = document.getElementById('T').value;
	if(N != '')
	{
		document.getElementById('showResults').innerHTML = '<div align="center"><img src="pleaseWait.gif"></div><br />';
		http.open("GET", 'ajax.php?N='+N+'&F='+F+'&T='+T, true);
		http.onreadystatechange = handleHttpResponse;
		http.send(null);
	}
}
	
// Response handler for state list
function handleHttpResponse()
{
	if (http.readyState == 4)
	{
		var response = http.responseText;				
		document.getElementById('showResults').innerHTML = response;
	}	
}
</script>
</head>
<body>
<span id="showResults"></span>
<form name="convert" id="convert" method="get" action="index.php" style="display:inline;">
 <table width="790"  border="1" align="center" cellpadding="5" cellspacing="0">
    <tr>
      <td colspan="2"><div align="center"><strong><font color="#990000" size="4" face="Georgia, Times New Roman, Times, serif">Exchange Rate Calculator </font></strong></div></td>
    </tr>
    <tr>
      <td width="50%"><strong><font color="#0000FF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Convert:</font></strong></td>
      <td width="50%"><input name="N" type="text" id="N" style="width:90%;" value="<?=$amount;?>"></td>
    </tr>
    <tr>
      <td width="50%"><strong><font color="#0000FF" size="2" face="Verdana, Arial, Helvetica, sans-serif">From:</font></strong></td>
      <td width="50%"><select name="F" id="F"  style="width:90%;">
	  <?php
	  if($from == NULL){$from = 'XAU';}
	  foreach($list as $code => $name){
	  	if($from == $code){$sel=' selected';}else{$sel=NULL;}
		echo '<option value="'.$code.'"'.$sel.'>'.$name.'</option>';
	  }
	  ?>
      </select></td>
    </tr>
    <tr>
      <td width="50%"><strong><font color="#0000FF" size="2" face="Verdana, Arial, Helvetica, sans-serif">To:</font></strong></td>
      <td width="50%"><select name="T" id="T"  style="width:90%;">
	  <?php
	  if($to == NULL){$to = 'USD';}
	  foreach($list as $code => $name){
	  	if($to == $code){$sel=' selected';}else{$sel=NULL;}
		echo '<option value="'.$code.'"'.$sel.'>'.$name.'</option>';
	  }
	  ?>
            </select></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
        <input type="button" name="Submit2" value="Convert" onClick="doAjax();">
        </div></td>
    </tr>
    <tr>
      <td colspan="2"><div align="right"><a href="http://www.LightPHPScripts.com" target="_blank"><font size="1"><strong>Powered by LPS</strong></font></a> </div></td>
    </tr>
  </table>
</form>
</body>
</html>
Return current item: Free PHP Ajax Currency Rate Exchanger Calculator