使用HTML5和javascript的货币Web服务 [英] Currency Web services using HTML5 and javascript
本文介绍了使用HTML5和javascript的货币Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请指导我在我的项目中添加了http://www.webservicex.net/currencyconvertor.asmx这种货币网络服务。我不知道怎么称呼这个网络我的代码中的服务,
Hi,
Please guide me i have added "http://www.webservicex.net/currencyconvertor.asmx" this currency web services in my project.I dont kniow how to call this web services in my code,
<!DOCTYPE html>
<head>
<title>Simple Currency Converter</title>
<style type="text/css">
<script type="text/javascript">
var symbol = ['US Dollar', 'British Pound', 'Euro',
'Canadian Dollar', 'Japanese Yen', 'Chinese Yuan', 'India', 'Singapore'];
var rates = [ // [symbol][USD, GBP, Euro, c$, Yen, Yuan, India, Singapore]
[1, 0.64, 0.74, 1.00, 93.83, 6.23, 53.04, 1.24],
[1.57, 1, 1.15, 1.56, 146.82, 9.76, 83.03, 1.94],
[1.36, 0.87, 1, 1.35, 127.39, 8.46, 72.01, 1.68],
[1.00, 0.64, 0.74, 1, 94.12, 6.25, 53.20, 1.24],
[0.01, 0.01, 0.01, 0.01, 1, 0.07, 0.57, 0.01],
[0.16, 0.10, 0.12, 0.16, 15.06, 1, 8.51, 0.20],
[0.02, 0.01, 0.01, 0.02, 1.74, 0.12, 1, 0.02],
[0.81, 0.51, 0.60, 0.81, 75.01, 5.03, 43.33, 1]
];
function $(x) { return document.getElementById(x); };
function $$(x) { return parseInt($(x).value, 10); };
window.onload = function () {
for (var i = 0; i < symbol.length; i++) {
$('cHave').options[i] = new Option(symbol[i], i);
$('cWant').options[i] = new Option(symbol[i], i);
}
$('amount').onfocus = function () { this.value = '' };
$('amount').onblur = calculate;
$('cHave').onchange = calculate;
$('cWant').onchange = calculate;
};
function calculate() {
var a = Math.abs($$('amount') || 0); $('amount').value = a;
var b = $$('cHave'), c = $$('cWant'), o = $('output');
if (a <= 0 || b >= rates.length || c >= rates[b].length) o.innerHTML = '';
else o.innerHTML = (a * rates[b][c]).toFixed(2) + ' ' + symbol[c];
return false; // force no submit
};
</script>
</head>
<body>
<h1>Simple Currency Converter</h1>
<hr/>
<div class="table" style="border:10px">
<form onsubmit="return calculate();" style="width: 341px">
<span class="style1">Amount (whole units)</span><input id="amount" value="0"/><br/>
<span>Convert</span><select id="cHave"></select><br/>
<span>Into</span><select id="cWant"></select><br/>
<span>Result</span><label id="output" /></div>
</form>
</div>
</body>
</html>
这是我的代码,请指导我在哪里添加这个网络服务进行货币兑换。
谢谢,
P.LakshmiPriya
This is my code please guide me where i have to add this webservices for currency conversion.
Thanks,
P.LakshmiPriya
推荐答案
,Yen,Yuan,India,Singapore]
[1,0.64,0.74,1.00,93.83,6.23,53.04,1.24],
[1.57,1,1.15,1.56,146.82,9.76,83.03,1.94],
[1.36, 0.87,1,1.35,127.39,8.46,72.01,1.68],
[1.00,0.64,0.74,1,94.12,6.25,53.20,1.24],
[0.01,0.01,0.01,0.01,1,0.07,0.57,0.01],
[0.16,0.10,0.12 ,0.16,15.06,1,8.51,0.20],
[0.02,0.01,0.01,0.02,1.74,0.12,1,0.02],
[0.81,0.51,0.60,0.81,75.01,5.03 ,43.33,1]
];
function
, Yen, Yuan, India, Singapore] [1, 0.64, 0.74, 1.00, 93.83, 6.23, 53.04, 1.24], [1.57, 1, 1.15, 1.56, 146.82, 9.76, 83.03, 1.94], [1.36, 0.87, 1, 1.35, 127.39, 8.46, 72.01, 1.68], [1.00, 0.64, 0.74, 1, 94.12, 6.25, 53.20, 1.24], [0.01, 0.01, 0.01, 0.01, 1, 0.07, 0.57, 0.01], [0.16, 0.10, 0.12, 0.16, 15.06, 1, 8.51, 0.20], [0.02, 0.01, 0.01, 0.02, 1.74, 0.12, 1, 0.02], [0.81, 0.51, 0.60, 0.81, 75.01, 5.03, 43.33, 1] ]; function
(x){return document.getElementById(x); };
函数
(x) { return document.getElementById(x); }; function
(x){return parseInt(
(x) { return parseInt(
这篇关于使用HTML5和javascript的货币Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文