GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Gemeinde Daten mit JSON in ein Formular holen  XML
Forum Index -> Forum in Deutsch
Author Message
maffy



Joined: 16/10/2008 18:41:03
Messages: 3
Offline

Ich habe ein Formular mit dem ich Gemeindedaten anlegen möchte.
Wenn eine PLZ eingegeben wurde sollen die Basisdaten wie LAT, LNG, Regierungsbezirk etc. von Geonames geholt werden und in die Formulafelder eingetragen werden.

Aber irgendwie funktioniert das nicht. Wo liegt der Fehler

Hier ist mal das Formular:
Code:
 	print "<h1>Gemeindeverzeichnis - Basisdaten anlegen:</h1>";		
 	print "<p><b>Gemeindebasisdaten neu anlegen</b>:</p>";
 
 	print "<form name='addnew' aktion='?do=gemeinde&aktion=save' method='post'>";
 	
 	print "<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";	
 	print "<LABEL for=\"Gemeindedaten\">Gemeinde: </LABEL>";
 	
 	print "<tr>";
     print "<td width=\"25%\">Gemeinde:</td>";
     print "<td><input name=\"gemeinde\" type=\"text\"  size=\"45\"></td>";
   	print "</tr>";
 	
 	print "<tr>";
     print "<td width=\"25%\">PLZ:</td>";
     print "<td><input name=\"plz\" type=\"text\" size=\"10\" onblur=\"search1();\" ></td>";
   	print "</tr>";
 	
 	print "<div id=\"resultDiv\"></div>";
 	
 	
 	print "</table>";
 		
 	print "<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
 	print "<LABEL for=\"Basisdaten\">Gemeinde - Basisdaten: </LABEL>";	
 	print "<tr>";
     print "<td width=\"25%\">Staat:</td>";
     print "<td><input name=\"Staat\" type=\"text\"  size=\"5\"></td>";
   	print "</tr>";	
 	print "<tr>";
     print "<td width=\"25%\">Bundesland:</td>";
     print "<td><input name=\"Bundesland\" type=\"text\"  size=\"5\"></td>";
   	print "</tr>";	
 	print "<tr>";
     print "<td width=\"25%\">Regierungsbezirk:</td>";
     print "<td colspan=\"2\"><input name=\"Regierungsbezirk\" type=\"text\"  size=\"45\"></td>";
   	print "</tr>";	
 	print "<tr>";
     print "<td width=\"25%\">Landkreis:</td>";
     print "<td><input name=\"Landkreis\" type=\"text\" size=\"45\"></td>";
   	print "</tr>";	
 	print "</table>";
 	
 	print "<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
 	print "<LABEL for=\"Geocode Daten\">Gemeinde - GPS: </LABEL>";
 	print "<tr><td width=\"25%\">Latitude:</td><td ><input name=\"lat\" type=\"text\" value=\"\" size=\"45\"></td><tr>";
 	print "<tr><td>Longtitude:</td><td ><input name=\"lon\" type=\"text\" value=\"\" size=\"45\"></td></tr>";				
 	print "<tr>";
 	print "</table>";
 	
 	print "<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
 	print "<LABEL for=\"Infotext\">Gemeinde - Infotext: </LABEL>";	
     print "<td colspan=\"2\"><textarea name=\"infotext\" cols=\"55\" rows=\"15\" id=\"infotext\"></textarea></td>";
   	print "</tr>";
 	print "</table>";
 
 	print "<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">";
 	print "<LABEL for=\"Aktionen\">Aktionen: </LABEL>";	
     print "<td > <input type='submit' value='Ok'>  </td>";
   	print "</tr>";	
 	print "</form>";	
 	print "</table>";
 


Hier ist das Javascript:
Code:
 	<script type="text/javascript" src="jsr_class.js"></script>
 
  	<script type="text/javascript">
 		
 	// <a href="http://ws.geonames.org/findNearbyPostalCodes?postalcode=97708&country=de&maxRows=1" target="_blank" rel="nofollow">http://ws.geonames.org/findNearbyPostalCodes?postalcode=97708&country=de&maxRows=1</a>
 		
 	// - <code>
   	// PLZ: <postalcode>97708</postalcode> 
   	// Gemeinde: <name>Bad Bocklet</name> 
  	// Land: <countryCode>DE</countryCode> 
 	// <lat>50.2667</lat> 
  	// <lng>10.0833</lng> 
   	// Bundesland: <adminCode1>BY</adminCode1> 
   	// <adminName1>Bayern</adminName1> 
  	// <adminCode2></adminCode2> 
   	// Regierungsbezierk: <adminName2>Unterfranken</adminName2>
   	// <adminCode3></adminCode3> 
   	// <adminName3>Landkreis Bad Kissingen</adminName3> 
  	// <distance></distance> 
  	// </code>
 
  function search1() {
   request = 'http://ws.geonames.org/findNearbyPostalCodesJSON?postalcode=' +  encodeURIComponent(document.getElementById("iplz").value)  + '&country=DE&maxRows=1&callback=getLocation'; 
   aObj = new JSONscriptRequest(request);
   aObj.buildScriptTag();
   aObj.addScriptTag();
   }
 
 function getLocation(data) {
 
 	var html = '<u><b>Daten gefunden:</b></u><br>';
 
 
 	for (i=0;i< data.length;i++) {
 	
 		var name = data[i];
 		html = html + '' + name.lat +',' + name.lng + '<br> ' +name.placeName + name.postalCode+' <br>';
 	}
 	
 	document.getElementById('resultDiv').innerHTML = html;
 
 
   
 }
 
  	</script>
 
 
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

hast du eine url wo man sehen kann wie es umgesetzt wird? Mit den vorliegenden Informationen weiss man weder, was das Problem ist, noch wie das Programm im Detail umgesetzt wurde.

Marc

[WWW]
 
Forum Index -> Forum in Deutsch
Go to:   
Powered by JForum 2.1.5 © JForum Team