Not yet rated

Problem

You need to retrieve data from a remote http source.

Solution

Use cfhttp to get the data, then parse it and display the result.

Detailed explanation

<cfhttp
url="http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1&s=USDEUR=X"
        method="get" 
        result="yahooData">

<cfset euro = listGetAt(yahooData.filecontent,2)>

<cfoutput>
<html>
<head>
<title>USD to EUR</title>
<script type="text/javascript">
     function calc(){
          document.getElementById('eur').value = #euro# *
          document.getElementById('usd').value;
     }
</script>
</head>
<body>

1 USD = #euro# Euro<br />

<form name="main">
    <input type="text" id="usd" name="usd" onKeyUp="calc()">
    $US Dollar <br /><br />
    <input type="text" id="eur" name="eur"
disabled="disabled">
    $Euro <br /><br />
</form>

</body>
</html>
</cfoutput>

Original and working demo: http://tutorial30.learncf.com/


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes