<script type="text/javascript">
function convert() {
var fromCur = document.getElementById('txtVal').value +
document.getElementById('ddlFrom').value;
document.getElementById('ddlFrom').value;
var ToCur = document.getElementById('ddlTo').value;
var strURL = 'http://www.google.com/ig/calculator?hl=en&q=' +
fromCur + '=?' + ToCur
//Url like this " http://www.google.com/ig/calculator?hl=en&q=1USD=?EUR"
//Url like this " http://www.google.com/ig/calculator?hl=en&q=1USD=?EUR"
var request = new XMLHttpRequest();
request.open("GET", strURL, false);
request.send(null);
if (request.responseText != "") {
document.getElementById('dv').innerHTML =
request.responseText.split('"')[1] + ' = '
+ request.responseText.split('"')[3]
}
}
</script>
HTML
:
Enter
Value to convert :<input type="text" id="txtVal" />
<br />
<asp:Literal ID="ltrfrom" runat="server"
Text="Select Currency to convert
:">
</asp:Literal>
<asp:DropDownList ID="ddlFrom" runat="server"
Style="vertical-align: middle;">
<asp:ListItem Text="SELECT" Value="0"></asp:ListItem>
<asp:ListItem Text="US Dollar" Value="USD"></asp:ListItem>
<asp:ListItem Text="Rupees" Value="INR"></asp:ListItem>
<asp:ListItem Text="GB Pound" Value="GBP"></asp:ListItem>
<asp:ListItem Text="Australia Dollar" Value="AUD"></asp:ListItem>
<asp:ListItem Text="CAnada Dollar" Value="CAD"></asp:ListItem>
<asp:ListItem Text="Switzerland Frank" Value="CHF"></asp:ListItem>
<asp:ListItem Text="Euro" Value="EUR"></asp:ListItem>
</asp:DropDownList>
<br />
<asp:Literal ID="ltrTo" runat="server"
Text="Select Currency convert to
:">
</asp:Literal>
<asp:DropDownList ID="ddlTo" runat="server"
Style="vertical-align: middle;">
<asp:ListItem Text="SELECT" Value="0"></asp:ListItem>
<asp:ListItem Text="US Dollar" Value="USD"></asp:ListItem>
<asp:ListItem Text="Rupees" Value="INR"></asp:ListItem>
<asp:ListItem Text="GB Pound" Value="GBP"></asp:ListItem>
<asp:ListItem Text="Australia Dollar" Value="AUD"></asp:ListItem>
<asp:ListItem Text="CAnada Dollar" Value="CAD"></asp:ListItem>
<asp:ListItem Text="Switzerland Frank" Value="CHF"></asp:ListItem>
<asp:ListItem Text="Euro" Value="EUR"></asp:ListItem>
</asp:DropDownList>
<br />
<input type="button" value="Get" onclick="convert();" />
<div id="dv">
</div>
No comments:
Post a Comment