function change_metal() { metal = document.getElementById('metal').options[document.getElementById('metal').selectedIndex].value; while (document.getElementById('feingehalt').length > 0) { document.getElementById('feingehalt').options[document.getElementById('feingehalt').length - 1] = null; } if (metal == 'Gold') { feingehalten = new Array(999,986,916,900,750,585,375,333); for (var i=0; i "9") && document.getElementById('gewicht').value.charAt(i) != ",") { chkGewicht = -1; } } for (i = 0; i < document.getElementById('gewicht').value.length; ++i) { if (document.getElementById('gewicht').value.charAt(i) == ",") { chkKommaAnz++; } lastZ = document.getElementById('gewicht').value.charAt(i); } if (chkGewicht == -1) { document.getElementById('gewicht_title').innerHTML = "Nur Ziffern oder Komma"; document.getElementById('gewicht_title').style.color = "#AA0000"; document.getElementById('gewicht').focus(); return false; } else if (chkKommaAnz > 1) { document.getElementById('gewicht_title').innerHTML = "Bitte nur 1 Komma eingeben"; document.getElementById('gewicht_title').style.color = "#AA0000"; document.getElementById('gewicht').focus(); return false; } else if (document.getElementById('gewicht').value == '') { document.getElementById('gewicht_title').innerHTML = "Bitte Menge eingeben"; document.getElementById('gewicht_title').style.color = "#AA0000"; document.getElementById('gewicht').focus(); return false; } else if (document.getElementById('gewicht').value.slice(0,1)==",") { document.getElementById('gewicht_title').innerHTML = "Bitte mit Ziffern beginnen"; document.getElementById('gewicht_title').style.color = "#AA0000"; document.getElementById('gewicht').focus(); return false; } else if (document.getElementById('gewicht').value == 0 || lastZ == ",") { document.getElementById('gewicht').focus(); return false; } else { if (document.getElementById('gewicht_title').innerHTML != "Gewicht") { document.getElementById('gewicht_title').innerHTML = "Gewicht"; document.getElementById('gewicht_title').style.color = colorOrigGewicht; } return true; } } function chkKurs() { var chkKurs = 1; if ((typeof colorOrigKurs) == "undefined") { colorOrigKurs = document.getElementById('kurs_title').style.color; } if ((typeof titleOrigKurs) == "undefined") { titleOrigKurs = document.getElementById('kurs_title').innerHTML; } for (i = 0; i < document.getElementById('kurs').value.length; ++i) { if (document.getElementById('kurs').value.charAt(i) < "0" || document.getElementById('kurs').value.charAt(i) > "9") { chkKurs = -1; } } if (chkKurs == -1) { document.getElementById('kurs_title').innerHTML = "Bitte nur Ziffern eingeben"; document.getElementById('kurs_title').style.color = "#AA0000"; document.getElementById('kurs').focus(); return false; } else { if (document.getElementById('kurs_title').innerHTML != titleOrigKurs) { document.getElementById('kurs_title').innerHTML = titleOrigKurs; document.getElementById('kurs_title').style.color = colorOrigKurs; } rechner_sumout(); } } var xmlHttpObject = false; if (typeof XMLHttpRequest != 'undefined') { xmlHttpObject = new XMLHttpRequest(); } if (!xmlHttpObject) { try { xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { xmlHttpObject = null; } } } function handleContent() { if (xmlHttpObject.readyState == 4 && xmlHttpObject.status == 200) { var daten = xmlHttpObject.responseText.split("|"); document.getElementById('kurs').value = daten[4]; document.getElementById('rechner_sumout').innerHTML = daten[1]+" "+daten[2]+" "+daten[0]+"
"+daten[3]+""; } } function rechner_sumout() { document.getElementById('rechner_sumout').innerHTML = ''; if (chkGewicht() != true) { document.getElementById('rechner_sumout').innerHTML = ''; return false; } else { var metal = document.getElementById('metal').options[document.getElementById('metal').selectedIndex].value; var gewicht = document.getElementById('gewicht').value; var gewichtseinheit = document.getElementById('gewichtseinheit').options[document.getElementById('gewichtseinheit').selectedIndex].value; var feingehalt = document.getElementById('feingehalt').options[document.getElementById('feingehalt').selectedIndex].value; var kurs = document.getElementById('kurs').value; xmlHttpObject.open('get','/goldrechner/inc/rechner.php?metal='+metal+'&gewicht='+gewicht+'&gewichtseinheit='+gewichtseinheit+'&feingehalt='+feingehalt+'&kurs='+kurs); xmlHttpObject.onreadystatechange = handleContent; xmlHttpObject.send(null); } } window.onload = change_metal;