Max: Javascript Euroumrechner

Beitrag lesen

Hi erst mal bin gerade dabei einen Javascripttaschenrechner für die Schule zu programmieren und komme grad nicht weiter hab mir auch schon selfhtml durchgelesen werde aber nicht wirklich schlauer dadurch.

Daher bräuchte ich mal eure hilfe bzw. anregung wie ich mein problem lösen könnte.

Hier erst mal der Quelltext:

<html>
<head>

<script language="JavaScript">
<!--

function umrechnen()
{
fehlersuche ()

var a=document.form.geldwert.value;
var b;

if (document.form.devisen.selectedIndex==0){b=1.1215;}
if (document.form.devisen.selectedIndex==1){b=0.6998;}
if (document.form.devisen.selectedIndex==2){b=1.5135;}
if (document.form.devisen.selectedIndex==3){b=133.3333;}
if (document.form.devisen.selectedIndex==4){b=34.9650;}
if (document.form.devisen.selectedIndex==5){b=53.1915;}
if (document.form.devisen.selectedIndex==6){b=4.2626;}
if (document.form.devisen.selectedIndex==7){b=31.2500;}
if (document.form.devisen.selectedIndex==8){b=7.4294;}
if (document.form.devisen.selectedIndex==9){b=1.5911;}
if (document.form.devisen.selectedIndex==10){b=1.9912;}
if (document.form.devisen.selectedIndex==11){b=39.0625;}
if (document.form.devisen.selectedIndex==12){b=1.7778;}
if (document.form.devisen.selectedIndex==13){b=6.6845;}
if (document.form.devisen.selectedIndex==14){b=10000.0000;}
if (document.form.devisen.selectedIndex==15){b=58.8235;}
if (document.form.devisen.selectedIndex==16){b=1.4550;}
if (document.form.devisen.selectedIndex==17){b=40.8163;}
if (document.form.devisen.selectedIndex==18){b=9.2851;}
if (document.form.devisen.selectedIndex==19){b=27.2480;}
if (document.form.devisen.selectedIndex==20){b=2.2321;}
if (document.form.devisen.selectedIndex==21){b=2.2095;}
if (document.form.devisen.selectedIndex==22){b=1.1161;}
if (document.form.devisen.selectedIndex==23){b=1.9806;}
if (document.form.devisen.selectedIndex==24){b=0.9196;}
if (document.form.devisen.selectedIndex==25){b=2.1782;}
if (document.form.devisen.selectedIndex==26){b=200.0000;}
if (document.form.devisen.selectedIndex==27){b=8.7489;}
if (document.form.devisen.selectedIndex==28){b=8.3682;}
if (document.form.devisen.selectedIndex==29){b=63.6943;}
if (document.form.devisen.selectedIndex==30){b=1.9794;}
if (document.form.devisen.selectedIndex==31){b=6.9061;}
if (document.form.devisen.selectedIndex==32){b=909.0909;}
if (document.form.devisen.selectedIndex==33){b=2.9949;}
if (document.form.devisen.selectedIndex==34){b=47.8469;}

var c = a/b;
document.form.eurowert.value="";
var d=Math.round(c*100)/100
if(document.form.runden[0].checked==true){document.form.eurowert.value=d;
}
else
{
document.form.eurowert.value=c;
}
}
function fehlersuche ()
{
if (document.form.geldwert.value=="")
alert ("Bitte geben sie einen Betrag ein");
document.form.geldwert.focus ();
document.form.geldwert.select ();
}
// -->
</script>

</head>

<body>

<table border=0 bordercolorlight="#000000" bordercolor="#000000" cellspacing="0" bordercolordark="#000000" width="329">
<tr>
<td bordercolor="#303030" bordercolorlight="#202020" bordercolordark="#303030" bgcolor="#808080" width="317">
<b><font size="5" color="#202020"></font><font size="5">Eurotaschenrechner</font></b></td>
</tr>

<form name="form">

<table border=0 bordercolorlight="#909090" bordercolor="#000000" cellspacing="1" bordercolordark="#000000" width="329">
<tr>
<td bgcolor="#CCCCCC" width="317>
<font face="Arial" color="black"><font class="stn">Betrag: </font>
<span style="background-color: #FFFF00">
<input type="text" name="geldwert" size="10"></span><br>
</tr>
</td>

<tr>
<td bgcolor="#CCCCCC" width="317>
<font class="stn">Ergebnis:</font>
<input type="radio" name="runden" value="runden" checked>gerundet
<input type="radio" name="runden" value="exakt">genau <br>
</tr>
</td>

<tr>
<td bgcolor="#CCCCCC" width="317>
<font class="stn">Währung:</font>
<select name="devisen" size="1">

<option selected>US-Dollar </option>
        <option>Englische Pfund</option>
        <option>Schweizer Franken</option>
        <option>Japanischer Yen </option>
        <option>Russischer Rubel</option>
        <option>Indische Rupie</option>
        <option>Polnischer Zloty</option>
        <option>Techechenische Krone</option>
        <option>Dänishce Krone</option>
        <option>Kanadischer Dollar</option>
        <option>Taiwanischer Dollar</option>
 <option>Australischer Dollar</option>
 <option>Ägyptisches Pfund</option>
 <option>Indonesische Rupiah</option>
 <option>Phillipinscher Peso</option>
 <option>Tunesischer Dinar</option>
 <option>Slowakische Krone</option>
 <option>Chinesischer Renmimbi</option>
 <option>Dominikanischer Peso</option>
 <option>Barbados-Dollar</option>
 <option>Belize-Dollar</option>
 <option>Bermuda-Dollar</option>
 <option>Brunei-Dollar</option>
 <option>Kaiman-Dollar</option>
 <option>Fidschi-Dollar</option>
 <option>Guyana-Dollar</option>
 <option>Hong-Kong Dollar</option>
 <option>Salomonen-Dollar</option>
 <option>Jamaikanischer Dollar</option>
 <option>Singapur Dollar</option>
 <option>Trinidad/Tobago Dollar</option>
 <option>Simbabwe-Dollar</option>
 <option>Ost-Karibischer Dollar</option>
 <option>Thailändischer Bath</option>

</select> <br>
</tr>
</td>

<tr>
<td bgcolor="#CCCCCC" width="317>
<font class="stb">Wechselkurs:</font>
<input type="text" name="wechselkurs" size="15"><br>
</tr>
</td>

<tr>
<td bgcolor="#CCCCCC" width="317>
<font class="stb">Berechneter Euro-Betrag:</font>
<input type="text" name="eurowert" size="15"> <br>
</tr>
</td>

<tr>
<td bgcolor="#CCCCCC" width="#202020">
<input type="button" value="Umrechnen" name="Umrechnen" onclick="umrechnen()">
<input type="reset" value="Zurücksetzen" name="reset">
</tr>
</td>

</form>
</td>
</tr>
</table>
</table>
</font>
</body>
</html>

Folgendes Problem: Ich hätte gern das er mir die Variable b im Feld Wechselkurs angezeigt wird und das man sie dort umändern kann.

Immoment ist es ja so das die eingegebenen Wechselkurse nicht veränderbar sind. Und wenn sich nun der ein oder andere Wechselkurs ändert kann man das programm nicht mehr verwehrten das würde ich gerne ändern indem ich sage das z.b der amerikanische doller nicht mehr 1.1215 sondern 2.1234 wäre und man diesen wert im feld wechselkurs ändern kann. So das das Programm vom benutzer aktualisiert wird falls der kurs nicht mehr übereinstimmt mit den vorgegebenen wechselkursen.

Ich hoffe das ich mein problem einigermaßen verdeutlichen konnte bin nicht so dolle im erklären und im programmieren daher fragt nach falls etwas unklar ist. Ich werde jede 10 min mal reinschaun.

Ich danke euch schon mal im vorraus für eure Hilfe.

mfg Max