function plz_ereg(ort_id, plz_id, suchstring) {
var wohnort = new Array();
wohnort[0] = new Object();
wohnort[0]["plz"] = "1010";
wohnort[0]["ort"] = "Wien";
wohnort[1] = new Object();
wohnort[1]["plz"] = "1020";
wohnort[1]["ort"] = "Wien";
...
// Treffer Variable initialisieren
var counter = "0";
for (var i = 0; i < wohnort.length; i++) {
if(wohnort[i]["plz"] == suchstring){
document.getElementById(ort_id).value = wohnort[i]["ort"];
counter++;
}
}
// Prüfen, ob PLZ eingegeben ist, jedoch kein Treffer erzielt wurde -> Wert des Felder Wohnort leeren
if((document.getElementById(plz_id).value != "") && (counter == "0")) {
document.getElementById(ort_id).value = "";
}
} |