Linking a textbox value to coinmill script for currency conversion

I got a currency exchange script from coinmill. I want to modify it to work nice in my page. I am a newbie in html/javascript programming thats why i am asking help on this one, pls.

<script src=""></script>
<script>
var currency_round=true;
var currency_decimalSeparator='.';
var currency_thousandsSeparator=',';
var currency_thousandsSeparatorMin=3;
</script>
$199.00 (US) = <script>currency_show_conversion(199.00,"USD","GBP");</script> GBP<br>
<small>Currency data courtesy <a href="">coinmill.com</a></small>

This scripts works fine but shows the conversion for the default value in the script. I need to replace the value ($199.00) to a value from a textbox of id "edit_1". Automatically after the user inserts the currency to exchange, the value will show in the page.

Thanks in Advance.

1 Answer

I am Stephen Ostermiller, and I run . You can make this work with the JavaScript currency API from Coinmill:

  • Put on onchange event on the textarea
  • Get the value from the text area using this.value
  • use the currency_convert(value,from,to) method that is available in frame.js to convert it into the currency of your choice
  • Write the value to where you want it in the page, for example with document.getElementById('results').innerHTML

Putting it all together:

<script src=""></script>
<script>
var currency_round=true;
var currency_decimalSeparator='.';
var currency_thousandsSeparator=',';
var currency_thousandsSeparatorMin=3;
</script>
<textarea id=edit_1 onchange="document.getElementById('results').innerHTML=currency_convert(this.value,'USD','GBP')"></textarea><br>
Converted into GBP:<div id=results></div>
<p><small>Currency data courtesy <a href="">coinmill.com</a></small></p>

Whene I enter "273" into the textarea, I then see "Converted into GBP: 176.32" on the page.

You can test out a live example on jsfiddle:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like