getElement in Loop

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 6
Joined: Sun Feb 09, 2020 9:28 pm

Mon Mar 16, 2020 6:28 am

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: Select all

		$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>";

function updatedocnamef() {
	var x = document.getElementById("iddocnames").value;
User avatar
php-forum GURU
php-forum GURU
Posts: 1191
Joined: Mon Feb 22, 2016 5:52 pm

Mon Mar 16, 2020 8:50 am

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)?
Post Reply