getElement in Loop

A

Anonymous

Guest
Hi all,

I'm using the code below to try and get the value of $DocNames when I change the DoCNames.
But is keeps giving me the very first record's data instead of the one I changed.
How do I refer to the spesific records I changed?

Thanks a lot

Code:
<?php
		$resulthistory = mysqli_query($mysqli, "SELECT * FROM ScanDocs");
		while($res = mysqli_fetch_array($resulthistory)) {
			echo "<tr>";
			$ID = $res['ID'];
			$DocNames = $res['DocNames'];
			$DocDescript = $res['DocDescript'];
			echo "<td><input type='text' name='DocNames' id='iddocnames'  onchange='updatedocnamef()' value='$DocNames'></td>";
		}
		?>
	</table>

<script>
function updatedocnamef() {
	var x = document.getElementById("iddocnames").value;
	alert(x);
}
</script>
 
Are you expecting your JavaScript to update the database (because it won't)?

If not, are you sure that the database has been updated (you haven't shown any code for this)?

Have you checked to see if the data is in your HTML source code (your HTML is not formed correctly from what you have posted, and may not have displayed on screen)?
 
Back
Top