В основном я хочу изменить значение входного текстового поля, основанного на щелчке div, который у меня есть в echo в приведенном ниже PHP, на значение Serial Number или $ stuff [7].Для каждого из результатов.
<form method='POST' action='move_audit.php'>
<div>
<label for='serial_no'>Serial Number * </label><br />
<input type='text' name='serial_no' id='serial_no' value=""/>
<br /><br />
<input type='submit' class='submit' value='Exchange'/>
</div>
</form>
<?php
include('include/dbConnection.php');
//SQL statement
$query = "CALL compoutofdate();";
$query1= "SELECT * FROM compaudit;";
//Execute prepared MySQL statement
$results = mysqli_query($dbc,$query) or die('Error querying database');
$results1 = mysqli_query($dbc,$query1) or die('Error querying database');
while($stuff = mysqli_fetch_array($results1))
{
echo "<div id='procsults' onclick='ChangeText();'>
<b>Employee Number:</b> $stuff[1]<br />
<b>Employee Name:</b> $stuff[2] $stuff[3] <br />
<b>Department:</b> $stuff[4]<br />
<b>Device Grid Location:</b> $stuff[5]<br />
<b>Status:</b> $stuff[6]<br />
<b>Serial Number:</b> $stuff[7]<br />
<b>Model:</b> $stuff[8]<br />
<b>MAC Address:</b> $stuff[9]<br />
<b>Received Date:</b> $stuff[10]<br />
<b>Exchanged:</b> $stuff[11]<br />
</div>
<script>
function ChangeText()
{
document.getElementById('serial_no').value =".$stuff[7].";
}
</script>";
}
//Close dbConnect
mysqli_close($dbc);
?>