This is a real easy one
1. Define a variable for the exchange rates (indexed 0 to x)
2. Provide a select drop down for the currencies (values 0 to x)
3. add an onchange event listener to the new select and point to the same function as used for your current select
4. Change the calculation to take the exchange rate into consideration
Code:
var exchangeRates = [1, 0.889, 1.234];
function update(){
var er = exchangeRates[document.getElementById("Currency").value];// selected exchange rate
var price = document.getElementById("Package").value;
var words = document.getElementById("words").value;
if (words != "") {
words = parseInt(words);
if (isNaN (words)) {
alert ("Please enter the number of words in figures");
document.getElementById("words").value = "";
return false;
}
}
var wordsOver2000 = words-2000;
if (wordsOver2000 <0) {wordsOver2000 = 0}
words = words - wordsOver2000;
var Tprice = (((price * words) + (price * .95 * wordsOver2000))*er).toFixed(2);
document.getElementById("Totprice").value = Tprice;
document.getElementById("Totprice2").innerHTML = "Your Quote Total Is: " + Tprice
}
Code:
<body>
<!--start quote generator -->
<div class="quote" id="quote">
<select name="Package" id = "Package" onchange = "update()">
<option value="0.052">STUDENTS THE 11th HOUR PACKAGE</option>
<option value="0.041">STUDENTS EXPRESS PACKAGE</option>
<option value="0.035" selected="selected">STUDENTS WORK in PROGRESS PACKAGE</option>
</select>
<select name="Currency" id = "Currency" onchange = "update()">
<option value="0" selected="selected">USD</option>
<option value="1">EUR</option>
<option value="2">CND</option>
</select>
x
<input type="text" id="words" onchange="update()" value="" />
WORDS<br />
= MYR
<input type = "text" id = "Totprice" readonly />
</div>
<!--end quote generator -->
</body>