我在網站上有一個貨幣計算器我正在努力。我讓它工作得很好,以便根據您使用的輸入正確輸出兩種貨幣。輸出一個javascript變量
但是現在我需要一條線來顯示計算髮生後顯示的確切匯率。
因此,不是顯示用戶輸入的內容,而是顯示1 GBP在目標貨幣中的價值。第一個結果將總是1英鎊,因爲這是唯一使用的基礎貨幣。
因此,例如: 1 GBP = X在目標貨幣
(例如: 「1 GBP是等於1.24 USD」 或1 GBP是等於1.5 EUR)
原始HTML低於
<script type="text/javascript">
(function() {
var js = document.createElement('script'); js.type = 'text/javascript'; js.async = true;
js.src = 'http://www.floatrates.com/scripts/converter.js';
var sjs = document.getElementsByTagName('script')[0]; sjs.parentNode.insertBefore(js, sjs);
})();
</script>
<script>
$(document).ready(function() {
$("#from").msDropdown();
})
</script>
<script>
$(document).ready(function() {
$("#to").msDropdown();
})
</script>
<form class="frConverter">
<div class="field-row">
<div class="from">
<label for="from">Sending From:</label>
<select id="from" value="gbp" name="base_currency" class="select-box">
<option value="GBP" data-image="http://inaramoneytran.wpengine.com/wp-content/plugins/monex/assets/img/uk.gif" data-imagecss="flag" selected="">United Kingdom Pounds - GBP</option>
</select>
<input type="text" name="base_value" size="10" value="1">
<input type="hidden" name="default_base" value="gbp">
</div>
<div class="to">
<label for="to">Sending To:</label>
<select id="to" value="USD" name="target_currency" class="select-box">
<option value="USD" data-image="http://inaramoneytran.wpengine.com/wp-content/plugins/monex/assets/img/us.gif" data-imagecss="flag">United States (Dollar) - USD</option>
<option value="GBP" data-image="http://inaramoneytran.wpengine.com/wp-content/plugins/monex/assets/img/uk.gif" data-imagecss="flag">United Kingdom (Pound) - GBP</option>
</select>
<input type="hidden" name="default_target" value="usd">
<input type="text" name="target_value" size="10" value="">
</div>
</div>
</form>
可以包含足夠的代碼使計算器的工作,並將其納入一個單一的片段中?使用帶有圖標的工具欄按鈕和'< >'就可以了 – mike510a
當然,我現在編輯了代碼 – pasinionline
代碼..在哪裏顯示結果? –