ich habe ein Javasript was bisher auch überall lief. Nur auf dem Linux root wo ich Xammp installiert habe will es einfach nicht. Auf Windows läuft es unter Xampp.
Hier mal das Sript
- Code: Select all
<script type="text/javascript">
<!--
function show_location(objInput)
{
if(!String(objInput.value).match(/^\d{5}$/))
{
objInput.form.ort.style.visibility="hidden";
}
else
{
window.dummie.location="plz.php?plz="+objInput.value;
}
}
function add_option(strText)
{
objList=document.frm.ort;
objList.options[objList.options.length]=new Option(strText);
if(!window.opera)
{
objList.size=objList.options.length;
}
objList.style.visibility='visible';
}
//-->
</script>
<form name='frm'>
<iframe src='plz.php'name='dummie'width='1'height='1'frameborder='0'style='visibility:hidden;'></iframe>
<center>
<b>PLZ:<b><br><input size='5'type='text'maxlength='5'name='plz_in'onkeyup='show_location(this)'><br>
<select name='ort'style='visibility:hidden'>
<option>?</option>
</select>
</form>
Zur kurzen Erklärung. Man gibt seine Postleitzahl ein und anhand dieser wird aus der Datenbank dann der passende Ort rausgesucht und angezeigt.
Hier die Datenbankanbindung
- Code: Select all
<script type="text/javascript">
<!--
function get_location()
{
if(typeof parent.dummie=='object' && typeof parent.document.frm.ort=='object')
{
objList = parent.document.frm.ort;
objList.options.length=0;
<?php
//Wurde Parameter übergeben?
if(isset($_GET['plz']))
{
include ('inc/config.php');
@mysql_connect($sqlhost,$sqluser, $sqlpwd) OR die(mysql_error());
mysql_select_db($db_name) OR die(mysql_error());
$sql = "select ort from plz where plz='$_GET[plz]'";
$result= mysql_query($sql) OR die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "\n\tparent.add_option('".$row['ort']."');";
}
}
?>
}
}
if(self==top)
{
document.location='index.php';
}
else
{
get_location();
}
//-->
</script>
Also die Datenbank ist vorhanden. Zugriff darauf habe ich auch