TAFE Student again - currency conversion

goldy300

New Member
Messages
33
Reaction score
0
Points
0
Well, this time I've gotta create a web application that allows the user to enter in an amount in which is already in AUD and converts it to what ever I have listed in the drop down list when onClick. This one I'd document.write to another page.

I wasn't sure about adding the value of what other currencies are to each var. Do I sort of have it? And I wasn't sure about assigning the "name" in the select list to a variable... is that like (document.form1.selectlist.name.value) ??
or just document.form1.name.value

Each exercise is different to what I've been helped with on the previous exercise.

Here is my mess:

HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Currency Converter </TITLE>

<script type="text/javascript">
function calc()

var usd, eur, gbp, nzd;
var currency;            // thought I may have to add this var for the select list??

var usd = (document.form1.usd.value);
var eur = (document.form1.eur.value);
var gbp = (document.form1.gbp.value);
var nzd = (document.form1.nzd.value);

var currency = (document.form1.currency.value);

var usd = 1.39329; //not sure if these currencies are correct. xe has inverse and normal.. or what ever??
var eur = 1.88496;
var gbp = 2.41916; // multiply by AUD here??
var nzd = ;



// was going to doc.write here
</script>

</HEAD>

<BODY>
<center>
<font face="arial" size="2">
<form name="form1">
Convert: <input type="text" name="amount" size="10" value="$0.00"> &nbsp; From AUD Australian Dollars into: &nbsp;

<select name="currency">
    <option name="usd">USD United States Dollars</option>
    <option name="eur">EUR Euro</option>
    <option name="gbp">GBP United Kingdom Pounds</option>
    <option name="usd">NZD New Zealand Dollars</option>
</select>
&nbsp;
<input type="button" name="convert" value="Go!" onClick="calc()">
</form>
</font>
</center>
</BODY>
</HTML>

Thanx guys!
 

xmakina

New Member
Messages
264
Reaction score
0
Points
0
Have you talked to your tutor? Have you done your own research? Why not ask fellow students? I know you've got access to an amout of help here, but why not use the resources you have to hand?

Option tagss use value as well as name. You may benefit from putting the currency values in the option tag and then calc(this.currency.selected) (or whatever the javascript is).

Also: look here for more info on <select> and JScript http://www.javascriptkit.com/jsref/select.shtml
 

dickey

New Member
Messages
128
Reaction score
0
Points
0
This is a simple task. And we would be glad to help. but in the end you stand to lose as you did not try to learn the concept behind. when you get stuck after carefully thinking of the logic of your solution, then we will help.

coz I.T. is not about coding, it is more on ideas and solution finding. Be an IT manager not a program coder.
 

goldy300

New Member
Messages
33
Reaction score
0
Points
0
Why do I feel like I've pushed the envelope in a help forum? This is all brand new to me... I know some of the syntax but am still very vague on it as a whole. Also what I found on Google about javascript and currency conversion was actual currency converters such as xe.com and other people converters. I've look at the source code on a few but they're either too complex for how I want to do it, which doesn't help me understand if I don't know what it means... or javascript was an external file.

I did actually have a go but felt like it needed something else. I'll look at the javascriptkit site and see and see if I can make sense of it there. thanks anyway.
 

xmakina

New Member
Messages
264
Reaction score
0
Points
0
Why do I feel like I've pushed the envelope in a help forum? This is all brand new to me...

You answered your own question. You are Learning. You don't know this from that. This forum is for "Help". So when you understand the basics, things like objects, threads, the stack and the heap, paranthesis, functions, parameters, this, >, <, ||, &&, == and all the other fundamentals that your course is teaching you, then your questions will be of the level to ask here.

We're here to help web designers debug scripts or come up with original ideas to new and interesting problems. Most of us have already done all these mundane school exercises, we don't want to do them again and they're what helped us learn.

If we'd been spoon fed we wouldn't be able to help you when you actually need it and you won't be able to help us as you won't understand the Why, only the How.

As said above, once you've tried then ask. Frankly, if you try and still need to ask here you should go talk to your tutor, not us, as they will understand the course and the one-to-one will be much more useful to you.
 

goldy30

New Member
Messages
60
Reaction score
0
Points
0
yeah ok... if I wasn't on holidays I'd be a TAFE to ask my teacher...

You know with all that you just wrote, wouldn't have just been easier to say... Goldy, you only have to multiply the text input, which was "amount" with the select list's name. last guy gave me the hint that the values in each option hold the conversion rate and thats it.

once I know it once, later I won't have to ask obviously stupid questions to people like you.
 

Jordan C

New Member
Messages
433
Reaction score
0
Points
0
Hi.
I hope this should help, I'm not very good at JavaScript, the number has to be whole, and the answer is in an alert.

HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Currency Converter </TITLE>

<script type="text/javascript">
function calc(){

answer=document.form1.amount.value*document.form1.currency.value
alert(answer)
}

</script>

</HEAD>

<BODY>
<center>
<font face="arial" size="2">
<form name="form1">
Convert: $<input type="text" name="amount" size="10" value=""> &nbsp; From AUD Australian Dollars into: &nbsp;

<select name="currency">
    <option name="usd" value='0.664'>USD United States Dollars</option>
    <option name="eur" value='0.486'>EUR Euro</option>
    <option name="gbp" value='0.384'>GBP United Kingdom Pounds</option>
    <option name="usd" value='1.111'>NZD New Zealand Dollars</option>
</select>
&nbsp;
<input type="button" name="convert" value="Convert" onClick="calc()">
</form><p></p>

</font>
</center>
</BODY>
</HTML>
 
Last edited:

goldy300

New Member
Messages
33
Reaction score
0
Points
0
You sure are grateful.

I am grateful! I post appreciation and thanks every time and those who do help me without criticism come out with some excellent advice. This other guy was basically telling me to go elsewhere and learn and come back when I've got a real problem, and not lame student exercises.

Don't get me wrong though.. I appreciate all the advice everyone here has given me. Even your explanation about the regular expression dickey :happysad:
 
Top