Check which input element is active using array

I have this input field as array

<input tpe="text" name="quantxt[]" id="quantxt" value="<?php echo $qty = $row['quantity']; ?>" onkeypress="showsubmit()">
<input style="width:80px;border-radius:10px;background-color:green;border:none;padding:5px;color:white;" type="submit" name="sub1" id="sub1" value="UPDATE">
			
			

and the script is

<script>
			
				function showsubmit()
				{
				
					
						document.getElementById("sub1").style.visibility = "visible";
				}
							

							
				
			
			</script>

how could I know when element 2 is active or when 3rd …

Can you give us an idea of what element 2 and element 3 are supposed to be?

Sure.
I am creating an array of input elements like this…

<?php
for($i=0;$i<=2;$i++)
{

?>

<input name="a1[]">
<?php
}
?>

Here full code

<?php
for($i=0;$i<=2;$i++)
{

?>
<table>
<tr>
<td><input name="a1[]" onkeypress="showbuton()"></td>
<input style="visibility:hidden;" type="submit" name="u1" id="u1">
</tr>
</table>
<?php
}
?>
<script>
		function showbuton()
		{
			document.getElementById("u1").style.visibility="visible";
		}

</script>

for input field first,it visible the submit button.
but not for others

You have the unique id repeated on several elements. That is bad, for each id needs to be unique on the page.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.