Page 1 of 1

Completely off topic but (Javascript question)

Posted: Sat Mar 10, 2007 6:20 pm
by The_phat_controlleruk
At UNI at the mo and I have a Javascript assignment, done most of it but stuck on part of it now and can not get any further. Are there any java guru's out there that could give some guidance???

Cheers

Posted: Sat Mar 10, 2007 7:01 pm
by Silky V
What do you need to know?

Posted: Sat Mar 10, 2007 7:02 pm
by Silky V
What do you need to know?

Posted: Sat Mar 10, 2007 8:02 pm
by The_phat_controlleruk
What I am supposed to do is correct a piece of code to correctly convert two currencies, this I have done, I now have to expand this to concert four currencies. I am no programmer, but I now need to expand the code, I have started and am now stuck, what is below is as far as I have got. Any help would be appreciated, even if it's just " you are completely barking up the wrong tree".

Cheers


<script language="JavaScript" >
var currencyType = new Array();
currencyType[0] = "Dollar (USD)";
currencyType[1] = "Euro (EUR)";
currencyType[2] = "Pound Sterling (GBP)";
currencyType[3] = "Japanese Yen (JPY)";
var currencyType2 = new Array();
currencyType2[0] = "Dollar (USD)";
currencyType2[1] = "Euro (EUR)";
currencyType2[2] = "Pound Sterling (GBP)";
currencyType2[3] = "Japanese Yen (JPY)";
var amountEntered;
currencyType = window.prompt('Please enter the currency you are changing from 0) Dollar 1) Euro 2) Pound 3) Yen','');
currencyType = parseFloat(currencyType);
currencyType2 = window.prompt('Please enter the currency you are changing to 0) Dollar 1) Euro 2) Pound 3) Yen','');
currencyType2 = parseFloat(currencyType2);
while ((currencyType < 0 || currencyType >3) && (currencyType2 < 0 || currencyType2 >3))
{
currencyType = window.prompt('Please re-enter - the currency you are changing from should be 0 or 3', '');
currencyType = parseFloat(currencyType);
}
{
currencyType2 = window.prompt('Please re-enter - the currency you are changing to should be 0 or 3', '');
currencyType2 = parseFloat(currencyType2);
}
amountEntered = window.prompt('Please enter the amount to be converted','');
amountEntered = parseFloat(amountEntered);
{
document.write('<BR>' + amountEntered + ' currencyType ' + amountEntered * 1.27 + ' Euros')
}
</script>