Click here to Skip to main content
12,355,505 members (70,774 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Javascript HTML5
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>

This is my code please guide me where i have to add this webservices for currency conversion.

Thanks,
P.LakshmiPriya
Posted 20-Feb-13 1:17am
Comments
LakshmiPriyaece 21-Feb-13 1:55am
   
Thanks for your reply plz guide me in the above code how to add the webservice link in java script insted of Var symbol and Var Rates.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Please go through below url which guide you to how to use web service in HTML 5.
If you need any help please let me know i can help in that.
Introduction to using jQuery with Web Services[^]
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100