I am trying to pass some data from the database to a few textboxes and textarea but i am currently stuck. I would really appreciate some help to solve this issue. this is the code i am working with. I am able to pass it to the table but not the textboxes.
<script>
function showUser(str) {
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getusers.php?q="+str,true);
xmlhttp.send();
}
</script>
html
<form>
<?php
$dropdown = "<select name='custid' onchange='showUser(this.value)'>";
while ($row = mysqli_fetch_assoc($result2))
{ $dropdown .= "\r\n<option value='{$row['custid']}'>{$row['custid']}</option>";
}
$dropdown .= "\r\n</select>";
?>
<p><label class="label" for="custid">Customer ID:</label><?php echo $dropdown; ?> <span class="ferror">* </span></p>
<br/>
<div id="txtHint"><b>Person info will be listed here.</b></div>
<p><label class="label" for="model">Model:</label><input id="model" type="text" name="model" size="20" maxlength="20" > </p>
<p><label class="label" for="imei">IMEI:</label><input id="imei" type="text" name="imei" size="20" maxlength="16" > </p>
<p><label class="label" for="issues">Issues:</label><textarea cols="40" rows="3" wrap="virtual" maxlength="100" id="issues" name="issues" > </textarea></span>
</p>
<p><label class="label" for="workdesc">Work Description:</label><textarea cols="40" rows="3" wrap="virtual" maxlength="100" id="workdesc" name="workdesc" > </textarea></span></p>
</form>
PHP code
<?php
$q = intval($_GET['q']);
include('connect.php');
$sql="SELECT * FROM customer WHERE custid = '".$q."'";
$result = mysqli_query($dbcon,$sql);
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Equipment</th>
<th>Manufacturer</th>
<th>Model</th>
<th>IMEI</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['custName'] . "</td>";
echo "<td>" . $row['equipment'] . "</td>";
echo "<td>" . $row['manufacturer'] . "</td>";
echo "<td>" . $row['model'] . "</td>";
echo "<td>" . $row['imei'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($dbcon);
?>
Thanks for any assistance its a major class project i need to get sorted.