Consider the following:
<? php foreach($queryResult as $res) : ?>
// output all table columns
<form onsubmit="return javascriptFunction(); " method="post">
<button id="b">edit</button>
</form>
<?php endforeach; ?>
Obviously, when the javascript function is called, the id of the buttons are the same, so:
document.getElementById(b).value;
won't work as expected. Is it possible to:
- Give each button a unique id attribute while it is created in the loop?
- Say I click the third button, is it possible for the javascript function to use that button that is clicked?
I absolutely have know idea how it can happen, looks like there's no way around it. Is this possible?