sceiler: Dynamische Auswahlliste aus einer Tabelle

Beitrag lesen

Momentan sieht es bei mir so aus:

finduser.php // Ist die Form wo alle Eingaben etc. getätigt werden

  
echo '		  
<tr>  
	<td>Supplier</td>'; ?>  
	<td><div id="txt2"><select name="selectsupplier" size="1" onChange="ajaxrequest("get_users_from_db.php", "content")">  
	<?php  
	while ($row = mysql_fetch_assoc($query_get_supplier))  
		{  
			echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';  
		}  
echo '  
			</select></div>  
	</td>  
<tr>';  
echo '  
<tr>  
	<td>User</td>  
	<td><div id="content"></div>';  
echo '  
	</td>  
</tr>';  
		  
?>

Die Funktion ajaxrequest() übergibt als 1. Parameter die .php Seite wo die ID verarbeitet werden soll und der 2. Wert gibt den Ort an, wo die 2. Auswahlliste mit den Mitarbeitern hin soll.

getuser.js

// create the XMLHttpRequest object, according browser  
function get_XmlHttp() {  
  // create the variable that will contain the instance of the XMLHttpRequest object (initially with null value)  
  var xmlHttp = null;  
  
  if(window.XMLHttpRequest) {		// for Forefox, IE7+, Opera, Safari, ...  
    xmlHttp = new XMLHttpRequest();  
  }  
  else if(window.ActiveXObject) {	// for Internet Explorer 5 or 6  
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  
  }  
  
  return xmlHttp;  
}  
  
// sends data to a php file, via POST, and displays the received answer  
function ajaxrequest(php_file, tagID) {  
  var request =  get_XmlHttp();		// call the function for the XMLHttpRequest instance  
  
  // create pairs index=value with data that must be sent to server  
  var  the_data = document.getElementById('txt2').innerHTML;  
  
  request.open("POST", php_file, true);			// set the request  
  
  // adds  a header to tell the PHP script to recognize the data as is sent via POST  
  request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");  
  request.send(the_data);		// calls the send() method with datas as parameter  
  
  // Check request status  
  // If the response is received completely, will be transferred to the HTML tag with tagID  
  request.onreadystatechange = function() {  
    if (request.readyState == 4) {  
      document.getElementById(tagID).innerHTML = request.responseText;  
    }  
  }  
}

get_users_from_db.php

<?php  
	include ("functions.php");  
	dbconnect();  
	  
	$id = $_POST['selectcompany'];  
	$query = mysql_query("SELECT id, contactName  
							FROM company  
							WHERE id = '$id'");  
	  
	while ($row = mysql_fetch_assoc($query))  
		{  
			echo '<option value="'.$row['id'].'">'.$row['contactName'].'</option>';  
		}  
?>

Es läuft auch alles augenscheinlich, also keine Fehlermeldungen. Jedoch bekomme ich keine Auswahlliste mit Mitarbeitern angezeigt.
Hast du vllt eine Idee wieso?