Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <?php
  2. $a=0;
  3. while($row = mysql_fetch_assoc($execute)){
  4. $ID = $row['id'];
  5. $name[] = $row['names'];
  6. echo "<button name="btn$ID" class='btnName' onClick='showForm()'>$name[$a]</button>";
  7. $a++;
  8. }
  9.  
  10. <div id="result" style="display: none;">
  11. //name from clicked buttons should be displayed here
  12. </div>
  13. ?>
  14.  
  15. <script type="application/javascript">
  16. function showForm(){
  17. document.getElementById('result').style.display="block";
  18. }
  19. </script>
  20.  
  21. function showForm(ev) {
  22. const name = ev.target.getAttribute("name");
  23. const result = document.getElementById('result')
  24. result.innerHTML = name;
  25. result.style.display = 'block';
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement