livesuche fehlerhaft

sonnyp

Grünschnabel
Hi Leute,

ich werde hier langsam verrückt.
Ich weiß nicht genau, wie ich die Ergebnisse meiner Livesuche, welche unter dem Textfeld als Liste ausgegeben werden, bei Mausklick in das Textfeld einfügen lassen kann.


autocompletePLZ.php
PHP:
<?php
  $db = new mysqli('', '' ,'', '');
  if(!$db) {
  } else {
      if(isset($_POST['plz'])) {
      $plz = $db->real_escape_string($_POST['plz']);
      if(strlen($plz) >0) {
        $query = $db->query("SELECT PLZ FROM T_Firma WHERE PLZ LIKE '$plz%' LIMIT 10");
	if($query) {
          while ($result = $query ->fetch_object()) {
              echo '<li style="list-style-type:none; onClick="fillPLZ(\''.$result->PLZ.'\');">'.$result->PLZ.'</li>';
	  }
	} 
        else {
	}
      } 
      else {
      } 
    } else {
      }
  }

?>


autocomplete.js
Code:
    function lookupPLZ(inputStringPLZ) {
      if(inputStringPLZ.length == 0) {
	$('#suggestionsPLZ').hide();
	} 
      else {
	$.post("autocompletePLZ.php", {plz: ""+inputStringPLZ+""}, function(data){
	  if(data.length >0) {
	    $('#suggestionsPLZ').show();
	    $('#autoSuggestionsListPLZ').html(data);
	  }
         }
        );
      }
    } 

	
    function fillPLZ(thisValue) {
       document.suche.plz.value = $('#inputStringPLZ').val(thisValue);;
      setTimeout("$('#suggestionsPLZ').hide();", 200);
    }

index.php
HTML:
    <form align="center" name="suche" action="index.php?site=suche.php" accept-charset="iso-8859-1" method="post">

     <input type="text" name="plz" value="PLZ" onClick="javascript:resetFieldPLZ()" 
	        id="inputStringPLZ" onkeyup="lookupPLZ(this.value);" onblur="fillPLZ();" />
     <div class="suggestionsBoxPLZ" id="suggestionsPLZ" style="display: none;">
      <div class="suggestionListPLZ" id="autoSuggestionsListPLZ">


ich wäre euch sehr dankbar, wenn ihr mir da helfen könntet :(

Gruß
Sonny
 

Neue Beiträge

Zurück