M.Dessel: übernahme PLZ in Formular

Beitrag lesen

Hallo zusammen,
ich habe ein PHP-Formular (nicht erschrecken, weil PHP). In diesem
Formular sind die beiden Eingabefelder PostalCode und City. Dort kann
ich Werte entweder manuell editieren und abspeichern oder mittels
JavaScript einen Ort auswählen und diesen dann in das Feld City übernehmen. Funkioniert auch so weit, so gut.
Ich hab einfertiges Script im Internet gefunden, was mir von der Lösung her sehr gut gefällt, doch leider habe ich keine Ahnung von JavaScript.
Dieses Tool übernimmt leider immer nur in ein Feld, entweder in City oder in PostalCode.
Ist es möglich die beiden JavaScript-Functions so umzuschreiben, dass sie die gefundene Postleizahl in Postalcode und die Stadt in City übernimmt?

Ich habe nachfolgend die beiden Codefetzen mal drangehängt.
Über eine Hilfe würde ich mich sehr freuen

mfg
M.Dessel

Anhang:

<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<lib.abook.php>>>>>>> Dies ist ein Auszug aus dem PHP-Formular
<<<<<<<<<<<<<<<<<<<<<<<<<

..
..
print("        <tr>\n\t");
print("          <td width="20%" class="label">");
print("            $inputfields[4]");
print("          </td>\n");
print("          <td class="inputbox">");
print("            <input type="text" name="PostalCode" size="5" maxlength="5" value="$array[10]">");
print("            <input type="text" name="City" size="25" maxlength="25" value="$array[9]">");

?>
                   <script type="text/javascript">
                     document.write('<input type="button" value="Select ..."'
                                     + ' onclick="window.open('plz_popup_neu.php?'
                                     + 'head=City&form=sof&elem=City'
                                     + '','fpop','width=612,height=150')">'
                                   );

</script>
                 <?

print("          </td>\n");
print("        </tr>\n");

..
..

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<plz_popup_neu.php>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
    <title>Auswahl PLZ</title>
    <script type="text/javascript">
     function parsedSearchParams() {
       var q = location.search.substring(1).split(/[&;]/);
       for (var i=0; i<q.length; i++) {
         var a = q[i].split(/=/);
         if (a[0]) {
           var k = unescape(a[0]),
               v = a[1]? unescape(a[1]) : null;
           if (typeof this[k] != "undefined") {
             if (typeof this[k] != "object") this[k] = [ this[k] ];
             this[k][this[k].length] = v;
           }
           else this[k] = v;
         }
       }
     }

function insertValue(oSel) {
        var oOpener, oForm, oElem;
        if ((oOpener = window.opener) && !oOpener.closed && oOpener.document) {
          if ((oForm = oOpener.document.forms[oPars.form]) && (oElem = oForm.elements[oPars.elem])) {
            oElem.value = oSel.options[oSel.selectedIndex].text;
          }
          else alert("Form element in opener window not found.");
        }
        else alert("Opener window already closed.")

window.close();
      }
      var oPars = new parsedSearchParams();
      //document.write(oPars.head);

</script>
  </head>
       <?php
             require("include/config.inc.php");

$sqlQuery = "SELECT * FROM $db_Postleitzahlen";
print("      <form action=""><p>");
print("        <select name="standort" onchange="insertValue(this)">");
print("          <option value="">Bitte wählen Sie!</option>");
                   $connID = @mysql_pconnect($db_host, $db_user, $db_pass) or
                           die($errorMsg[1]."<br>ErrorNo. ".mysql_errno()."<br>MySQL said: ".mysql_error());
                   @mysql_select_db($db_db, $connID) or
                           die($errorMsg[2]."<br>ErrorNo. ".mysql_errno()."<br>MySQL said: ".mysql_error());
                   $result  = @mysql_query($sqlQuery, $connID) or die($errorMsg[3]);
                   if ($result){
                     while ($array = mysql_fetch_array($result)){
                       $id  = $array['plzID'];
                       $plz = $array['PLZ'];
                       $ort = $array['Ort'];
print("                <option value="$id">$plz $ort</option>");
                     } //endwhile
                   } //endif
print("        </select>");
print("      </p></form>");

?>
  </body>
</html>